|
So it would be up to each subclass to determine if the event was handled?
If it's not broken, fix it until it is
|
|
|
|
|
|
Ok, so I modified your approach just a bit:
public abstract class BaseViewModel
{
public ViewTypes ViewType { get; protected set; }
public BaseViewModel()
{
ViewType = ViewTypes.None;
AppCore.DataReceived += AppCore_DataReceived;
}
public void AppCore_DataReceived(object sender, DataReceivedArgs args)
{
if (CanHandleDataReceived(args))
{
DataReceived(args);
}
}
protected virtual bool CanHandleDataReceived(DataReceivedArgs args)
{
return ViewType == args.ViewType;
}
protected abstract void DataReceived(DataReceivedArgs args);
}
The subclasses now only need to set the ViewType property. Then this code checks for the type and if it matches, calls the abstract DataReceived.
What do ya think?
If it's not broken, fix it until it is
|
|
|
|
|
I was thinking just that!
|
|
|
|
|
Have a .net 4.0 application that when installed on Win 7 or 10 having issues with not being able to update the config file. Where is the proper location for the app.Exe.Config file?
|
|
|
|
|
The 'proper' location for app.exe.config is in the same directory/folder as app.exe
I'm not even sure if you can have app.exe.config in a different folder (if you're using the standard App Config do-dads) - I'd have to look it up
|
|
|
|
|
The proper location is in the same folder with the .EXE, usually in a folder under Program Files.
The problem is Program Files and everything under it is ReadOnly to normal users.
You really should NOT be writing to app.config. A proper method would be to write the changeable data to another config file in a folder under CommonAppData (see Environment.GetFolderPath).
|
|
|
|
|
So what is the proper method and what elements should be stored in the app.Exe.Config? I have a client application that stores both application settings and the connection strings to connect to the database.
Where can I find best practices on this?
|
|
|
|
|
|
My question is: I want to know the index of /* and */ coming immediate before alpha2
Example:
hello world /* this is */ right way to get the index of /* track to */ alpha2 dummy text alpha dummy /* test */textalpha dummy text
Thanks in advance
|
|
|
|
|
A Regular Expression[^] is probably the simplest way:
string input = @"hello world /* this is */ right way to get the index of /* track to */ alpha2 dummy text alpha dummy /* test */textalpha dummy text";
Regex pattern = new Regex(@"\/\*[^\*\/]*\*\/\s+alpha2");
Match match = pattern.Match(input);
if (match.Success)
{
int theIndex = match.Index;
...
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks Homer,
Its good but is there any way without the regular expression as I have to search from a file and there are a lot of same keywords like alpha2. with this regular expression It will be difficult to find specific instance and its immediate before characters. Actually I have to track the keywords which are not coming in comments section. Not coming in /* */ and not started with //. comment may be of many lines. Can you please suggest the solution.
Thanks in advance.
Rohit
|
|
|
|
|
|
Imports System
Imports System.IO
Imports System.Security.Cryptography
Imports System.Text
Friend Module #=qnhMLJurfpCWeGTTrMp3zBjm4bT7W4Gu70ST3HDDMUvo=
Friend Function #=q_ppzL1ZMYuGAEacS2FNOow==(ByVal u0023u003dqoh0ULu0024aAZVl6oonbDD8nVQu003du003d As String, ByVal u0023u003dqUG3UZJJnuLYlguu0024yNB5nSAu003du003d As String) As String
Dim numArray As Byte() = Nothing
Dim numArray1 As Byte() = Nothing
Dim passwordDeriveByte As PasswordDeriveBytes = Nothing
If (u0023u003dqoh0ULu0024aAZVl6oonbDD8nVQu003du003d.Length = 0) Then
Return ""
End If
Dim bytes As Byte() = Encoding.ASCII.GetBytes("GhqBYxD5sW1Hvh7r")
If (4 <> 0) Then
numArray = bytes
Else
End If
Dim numArray2 As Byte() = Convert.FromBase64String(u0023u003dqoh0ULu0024aAZVl6oonbDD8nVQu003du003d)
If (0 = 0) Then
numArray1 = numArray2
Else
End If
Dim passwordDeriveByte1 As PasswordDeriveBytes = New PasswordDeriveBytes(u0023u003dqUG3UZJJnuLYlguu0024yNB5nSAu003du003d, Nothing)
If (0 = 0) Then
passwordDeriveByte = passwordDeriveByte1
Else
End If
Dim bytes1 As Byte() = passwordDeriveByte.GetBytes(32)
Dim rijndaelManaged As System.Security.Cryptography.RijndaelManaged = New System.Security.Cryptography.RijndaelManaged() With
{
.Mode = CipherMode.CBC
}
Dim cryptoTransform As ICryptoTransform = rijndaelManaged.CreateDecryptor(bytes1, numArray)
Dim memoryStream As System.IO.MemoryStream = New System.IO.MemoryStream(numArray1)
Dim cryptoStream As System.Security.Cryptography.CryptoStream = New System.Security.Cryptography.CryptoStream(memoryStream, cryptoTransform, CryptoStreamMode.Read)
Dim numArray3(CInt(numArray1.Length) - 1) As Byte
Dim num As Integer = cryptoStream.Read(numArray3, 0, CInt(numArray3.Length))
memoryStream.Close()
cryptoStream.Close()
Return Encoding.UTF8.GetString(numArray3, 0, num)
End Function
Friend Function #=q6As9fqtPs9VXgnilv68uIQ==(ByVal u0023u003dqV7rw1c8rt3L9lxbG3YKFwwu003du003d As String, ByVal u0023u003dqHHfPvwyiLsPiMz1KklCg8wu003du003d As String) As String
Dim numArray As Byte() = Nothing
Dim numArray1 As Byte() = Nothing
Dim passwordDeriveByte As PasswordDeriveBytes = Nothing
If (u0023u003dqV7rw1c8rt3L9lxbG3YKFwwu003du003d.Length = 0) Then
Return ""
End If
Dim bytes As Byte() = Encoding.UTF8.GetBytes("GhqBYxD5sW1Hvh7r")
If (1 <> 0) Then
numArray = bytes
Else
End If
Dim bytes1 As Byte() = Encoding.UTF8.GetBytes(u0023u003dqV7rw1c8rt3L9lxbG3YKFwwu003du003d)
If (0 = 0) Then
numArray1 = bytes1
Else
End If
Dim passwordDeriveByte1 As PasswordDeriveBytes = New PasswordDeriveBytes(u0023u003dqHHfPvwyiLsPiMz1KklCg8wu003du003d, Nothing)
If (0 = 0) Then
passwordDeriveByte = passwordDeriveByte1
Else
End If
Dim bytes2 As Byte() = passwordDeriveByte.GetBytes(32)
Dim rijndaelManaged As System.Security.Cryptography.RijndaelManaged = New System.Security.Cryptography.RijndaelManaged() With
{
.Mode = CipherMode.CBC
}
Dim cryptoTransform As ICryptoTransform = rijndaelManaged.CreateEncryptor(bytes2, numArray)
Dim memoryStream As System.IO.MemoryStream = New System.IO.MemoryStream()
Dim cryptoStream As System.Security.Cryptography.CryptoStream = New System.Security.Cryptography.CryptoStream(memoryStream, cryptoTransform, CryptoStreamMode.Write)
cryptoStream.Write(numArray1, 0, CInt(numArray1.Length))
cryptoStream.FlushFinalBlock()
Dim array As Byte() = memoryStream.ToArray()
memoryStream.Close()
cryptoStream.Close()
Return Convert.ToBase64String(array)
End Function
End Module
|
|
|
|
|
Since when does CodeProject provide a free hacker service?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
That's not going to happen.
We're not going to reverse the strings for you because we have no idea who really owns that code. It's obfuscated for a reason.
|
|
|
|
|
This site is for those who code, not for hackers.
Just 1 hint: This not C or C++ or C#.
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
|
|
|
|
|
I think it "encrypts" passwords ... it does not "contain" a password (except for perhaps a seed).
|
|
|
|
|
Hi, I'm coding a C# program to include a dll I previously compiled but I keep getting the error:
The type or namespace name 'Form' could not be found (are you missing a using directive or an assembly reference?)
The code is:
using System;
using System.Threading;
using System.Collections.Generic;
using System.Reflection;
using System.IO;
namespace Threshold
{
public partial class Form1 : Form
{
IDictionary<string, Assembly> _libs = new Dictionary<string, Assembly>();
public Form1()
{
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
InitializeComponent();
}
}
I am probably just making a rookie mistake.
Please advise.
Thanks
|
|
|
|
|
You are using the class "Form", which is declared in the namespace "System.Windows.Forms". Add a using;
using System.Windows.Forms
..or use the classname and namespace to specify where you want to inherit from;
public partical class Form1 : System.Windows.Forms.Form Also make sure you have a reference to the forms' assembly.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Ok, that fixed that...
Now the errors are:
The type 'System.ComponentModel.IComponent' is defined in an assembly that is not referenced. You must add a reference to assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
The type 'System.ComponentModel.ISynchronizeInvoke' is defined in an assembly that is not referenced. You must add a reference to assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
The type 'System.ComponentModel.Component' is defined in an assembly that is not referenced. You must add a reference to assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
Only thing is I'm using Visual studio 2012 ultimate. I can't seem to find the assemblies in:
Project > Add Reference > Framework
Any ideas?
|
|
|
|
|
Member 12244972 wrote: I can't seem to find the assemblies in: The system assembly would already be in the references, if you created the project using VS. Are you mixing .NET framework versions?
What .NET version is the DLL targetting that you created?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Ok, I understand your point. The dll was targetting .net v2.0 and the program .net v4.6.1
I rebuilt the dll targetting .net v4.6.1
Still the same issue after restarting the Visual studio.
The type 'System.ComponentModel.IComponent' is defined in an assembly that is not referenced. You must add a reference to assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
The type 'System.ComponentModel.ISynchronizeInvoke' is defined in an assembly that is not referenced. You must add a reference to assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
The type 'System.ComponentModel.Component' is defined in an assembly that is not referenced. You must add a reference to assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
Any ideas?
|
|
|
|
|
Member 12244972 wrote: The dll was targetting .net v2.0 and the program .net v4.6.1 Should work, might have problems if it was the other way around.
Only thing I can think of, is that you might be targetting the wrong CPU-type; if the DLL is compiled for 64 bits, and the app is targetting 32 bits, or the other way around.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Open up the csproj file in a text editor and look for this line:
<Reference Include="System" /> If the line isn't there, include it alongside your other references.
This space for rent
|
|
|
|