public List <IdLoginClient> GetAllClients(int id) { List <IdLoginClient> res = new List <IdLoginClient>(); UsersContext usersContext = new UsersContext(); //string strId = Convert.ToString(id.Id); var buffer = usersContext.users.Select(i => new { Id = i.Id, Login = i.Login }).ToList(); foreach (var v in buffer) { res.Add(new IdLoginClient() { Id = Convert.ToString(v.Id), Login = v.Login }); } //Encrypt the users data Session sender = FindSessionByClientId(id); string actualKey = ExtensionClass.ByteArrayToString(sender.ServerKey); string subActualKey = actualKey.Substring(0, 8); IdeaChipher idea = new IdeaChipher(subActualKey); for (int i = 0; i < res.Count; i++) { res[i].Id = idea.Encrypt(res[i].Id); res[i].Login = idea.Encrypt(res[i].Login); } return(res); }
public int GetCountAndNamesOfFiles(out string projectName, out string[] fileNames, int senderId, int forId) { int count; string pathString = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); pathString = System.IO.Path.Combine(pathString, forId + "-" + senderId); string[] directories = Directory.GetDirectories(pathString); string projectName_ = directories[0]; string[] fileNames_ = Directory.GetFiles(projectName_); Session sender = FindSessionByClientId(forId); string actualKey = ExtensionClass.ByteArrayToString(sender.ServerKey); string subActualKey = actualKey.Substring(0, 8); IdeaChipher idea = new IdeaChipher(subActualKey); count = fileNames_.Length; projectName = idea.Encrypt(projectName_); fileNames = new string[fileNames_.Length]; for (int i = 0; i < fileNames_.Length; i++) { fileNames[i] = idea.Encrypt(fileNames_[i]); } return(count); }
/// <summary> /// Finds a class by class name using the auto-import information provided. /// </summary> /// <param name="className">is the class name to find</param> /// <param name="requireAnnotation">whether the class must be an annotation</param> /// <param name="forAnnotationUse">whether resolving class for use with annotations</param> /// <param name="extension">for additional classes</param> /// <returns>class</returns> /// <throws>TypeLoadException if the class cannot be loaded</throws> protected Type ResolveClassInternal( string className, bool requireAnnotation, bool forAnnotationUse, ExtensionClass extension) { if (forAnnotationUse) { switch (className.ToLowerInvariant()) { case "private": case "privateattribute": return typeof(PrivateAttribute); case "protected": case "protectedattribute": return typeof(ProtectedAttribute); case "public": case "publicattribute": return typeof(PublicAttribute); case "buseventtype": case "buseventtypeattribute": return typeof(BusEventTypeAttribute); } } // attempt extension classes i.e. classes part of epl or otherwise not in classpath var clazzExtension = extension.FindClassByName(className); if (clazzExtension != null) { return clazzExtension; } // Attempt to retrieve the class with the name as-is try { return ClassForNameProvider.ClassForName(className); } catch (TypeLoadException) { if (Log.IsDebugEnabled) { Log.Debug("Class not found for resolving from name as-is '" + className + "'"); } } // check annotation-specific imports first if (forAnnotationUse) { var clazzInner = CheckImports(_annotationImports, requireAnnotation, className); if (clazzInner != null) { return clazzInner; } } // check all imports var clazz = CheckImports(_imports, requireAnnotation, className); if (clazz != null) { return clazz; } // No import worked, the class isn't resolved throw new TypeLoadException("Unknown class " + className); }
private static ExprConstantNode ResolveIdentAsEnumConst( string constant, ImportServiceCompileTime classpathImportService, ExtensionClass classpathExtension) { var enumValue = ImportCompileTimeUtil.ResolveIdentAsEnum(constant, classpathImportService, classpathExtension, false); return enumValue != null ? new ExprConstantNodeImpl(enumValue) : null; }
public string Search(string word, string transform) { var text = Search(word); text = ExtensionClass.ExtractFromHtml(text, transform); if (text == "") { text = ExtensionClass.NOTRANSLATION; } return(text); }
public void SearchAndValidate() { SelectBrowser((int)Browser.Chrome); browser.FindElement(GooglePageObjects.searchBox).SendKeys("topdanmark"); ExtensionClass.FindElement(GooglePageObjects.dropdownResultList, browser); string topResult = browser.FindElement(GooglePageObjects.dropdownResultList).Text; Assert.AreEqual("topdanmark", topResult); }
static void Main(string[] args) { ExtensionClass obj = new ExtensionClass(); int result = obj.MultiplicationNumber(20, 30); Console.WriteLine(result); Console.ReadLine(); int Number = 20; Console.WriteLine(Number.CheckOddEven()); Console.ReadLine(); }
public void OpenWebPageOnFireFox() { SelectBrowser((int)Browser.Firefox); browser.Navigate().GoToUrl(TopdanmarkPageObject.topdanmarkurl); try { ExtensionClass.FindElement(TopdanmarkPageObject.topdanmarkLogo, browser); } catch { Assert.Fail("Not able to load the webpage on Firefox"); } }
public Type ResolveClass( string className, bool forAnnotation, ExtensionClass extension) { Type clazz; try { clazz = ResolveClassInternal(className, false, forAnnotation, extension); } catch (TypeLoadException e) { throw MakeClassNotFoundEx(className, e); } return clazz; }
public MethodInfo ResolveMethodOverloadChecked( string className, string methodName, ExtensionClass classpathExtension) { Type clazz; try { clazz = ResolveClassInternal(className, false, false, classpathExtension); } catch (TypeLoadException e) { throw new ImportException("Could not load class by name '" + className + "', please check imports", e); } return(ResolveMethodInternalCheckOverloads(clazz, methodName, MethodModifiers.REQUIRE_STATIC_AND_PUBLIC)); }
public static VariableMetaData CompileVariable( String variableName, String variableModuleName, NameAccessModifier variableVisibility, String optionalContextName, NameAccessModifier? optionalContextVisibility, String optionalModuleName, ClassIdentifierWArray variableType, bool isConstant, bool compileTimeConstant, Object initializationValue, ImportService importService, ExtensionClass extensionClass, EventBeanTypedEventFactory eventBeanTypedEventFactory, EventTypeRepositoryImpl eventTypeRepositoryPreconfigured, BeanEventTypeFactory beanEventTypeFactory) { try { return GetTypeInfo( variableName, variableModuleName, variableVisibility, optionalContextName, optionalContextVisibility, optionalModuleName, variableType, false, isConstant, compileTimeConstant, initializationValue, importService, extensionClass, eventBeanTypedEventFactory, eventTypeRepositoryPreconfigured, beanEventTypeFactory); } catch (VariableTypeException t) { throw new ExprValidationException(t.Message, t); } catch (Exception t) { throw new ExprValidationException("Failed to compile variable '" + variableName + "': " + t.Message, t); } }
//public MainWindow ServiceWindow //{ // get; set; //} public bool SendToServer(string encryptedMessage, int idFrom, string fileName, string containerName) { bool res = false; try { Session sender = FindSessionByClientId(idFrom); int idTo; string actualKey = ExtensionClass.ByteArrayToString(sender.ServerKey); string subActualKey = actualKey.Substring(0, 8); IdeaChipher idea = new IdeaChipher(subActualKey); //string encryptedMessageOld = encryptedMessage; if (idea.SurrogatePairsDetected(encryptedMessage)) { encryptedMessage = idea.DeleteAdditionalPartsFromSurrogetePairs(encryptedMessage); } string idRecipientStr = encryptedMessage.Substring(encryptedMessage.Length - 4, 4); encryptedMessage = encryptedMessage.Substring(0, encryptedMessage.Length - 4); idRecipientStr = idea.Decrypt(idRecipientStr); idTo = Convert.ToInt32(idRecipientStr); string buffer = idea.Decrypt(encryptedMessage); WriteToFile(buffer, fileName, containerName, idFrom, idTo); //WriteToFile(encryptedMessageOld, fileName + ".enc", containerName, idFrom, idTo); res = true; } catch (Exception ex) { res = false; throw ex; } return(res); }
public static List <IconFile> GetIcons(string path, int layers = 2) { if (!Directory.Exists(path)) { throw new Exception("Invalid Path"); } var Out = new List <IconFile>(400); try { foreach (var file in ExtensionClass.GetFiles(path, "*.ico", layers)) { Out.Add(new IconFile(file)); } } catch (UnauthorizedAccessException) { } return(Out); }
public static ValueAndFieldDesc ResolveIdentAsEnumConst( string constant, ImportServiceCompileTime importService, ExtensionClass classpathExtension, bool isAnnotation) { EnumValue enumValue = ResolveIdentAsEnum(constant, importService, classpathExtension, isAnnotation); if (enumValue == null) { return null; } try { return new ValueAndFieldDesc(enumValue.EnumField.GetValue(null), enumValue.EnumField); } catch (MemberAccessException e) { throw new ExprValidationException( "Exception accessing field '" + enumValue.EnumField.Name + "': " + e.Message, e); } }
public void PopulateCalendarWhenEmployeeAbsent(DateTime start, DateTime end, int employeeID) { List <Realization> realizations = new List <Realization>(); foreach (DateTime day in ExtensionClass.EachDay(start, end)) { Realization realization = new Realization(); realization.Hours = 8; realization.ProjectID = 1; realization.RealizationTypeID = 1; realization.Subject = "Absence"; realization.Description = "Absence"; realization.EmployeeID = employeeID; realization.Start = day; realization.DepartmentID = 1; realizations.Add(realization); } db.Realizations.AddRange(realizations); db.SaveChanges(); }
public string SignIn(string login, string password) { string res = string.Empty; if (login.Equals(string.Empty) || password.Equals(string.Empty)) { throw new ArgumentException("SignIn method. Empty parameters!"); } Session sender = FindSessionByClientId(defaultClientId); string actualKey = ExtensionClass.ByteArrayToString(sender.ServerKey); string subActualKey = actualKey.Substring(0, 8); IdeaChipher idea = new IdeaChipher(subActualKey); if (idea.SurrogatePairsDetected(login)) { login = idea.DeleteAdditionalPartsFromSurrogetePairs(login); } if (idea.SurrogatePairsDetected(password)) { password = idea.DeleteAdditionalPartsFromSurrogetePairs(password); } login = idea.Decrypt(login); password = idea.Decrypt(password); //should be changed to custom deleting the spaces only at the right side login = login.Trim(); password = password.Trim(); int id = GetIdAndVerifyPas(login, password); res = id.ToString(); res = idea.Encrypt(res); //ServiceWindow.LogTextBlock.Text += string.Format("Sign in id: {0} ", res); return(res); }
private void GenerateForClass( ExtensionClass extensionClassParameters, CodeFileCSharp input, CodeFileCSharp output, IMetadataRecorder metadataRecorder) { var unit = CompilationUnit(); unit = unit.AddUsings( UsingDirective(ParseName("System")), UsingDirective(ParseName("System.Collections.Generic")), UsingDirective(ParseName("System.Linq"))); var extensionClass = ClassDeclaration(extensionClassParameters.ExtensionClassName); extensionClass = extensionClass.AddModifiers(Token(SyntaxKind.PublicKeyword), Token(SyntaxKind.StaticKeyword), Token(SyntaxKind.PartialKeyword)); extensionClass = extensionClass .WithMembers( List <MemberDeclarationSyntax>( extensionClassParameters .Members .Where(m => m.Include) .Select(m => this.CreateExtensionMethod(m, input.SemanticModel)))); var nsContainer = NamespaceDeclaration(ParseName(this.Settings.OutputNamespace)); nsContainer = nsContainer.AddMembers(extensionClass); unit = unit.AddMembers(nsContainer); output.SyntaxTree = unit.SyntaxTree; metadataRecorder.SymbolGenerated( output.NodePathService, extensionClass, input.NodePathService, extensionClassParameters.RelatedClassDeclaration, new Dictionary <string, string>()); }
public string[] GetContents(string[] encryptedNames, int idFor) { string[] result = new string[encryptedNames.Length]; Session sender = FindSessionByClientId(idFor); string actualKey = ExtensionClass.ByteArrayToString(sender.ServerKey); string subActualKey = actualKey.Substring(0, 8); IdeaChipher idea = new IdeaChipher(subActualKey); string[] decryptedNames = new string[encryptedNames.Length]; for (int i = 0; i < encryptedNames.Length; i++) { decryptedNames[i] = idea.Decrypt(encryptedNames[i]); } for (int i = 0; i < result.Length; i++) { result[i] = File.ReadAllText(decryptedNames[i]); result[i] = idea.Encrypt(result[i]); } return(result); }
public MethodInfo ResolveMethodOverloadChecked( string className, string methodName, Type[] paramTypes, bool[] allowEventBeanType, bool[] allowEventBeanCollType, ExtensionClass extension) { Type clazz; try { clazz = ResolveClassInternal(className, false, false, extension); } catch (TypeLoadException e) { throw new ImportException( "Could not load class by name '" + className + "', please check imports", e); } try { return MethodResolver.ResolveMethod( clazz, methodName, paramTypes, false, allowEventBeanType, allowEventBeanCollType); } catch (MethodResolverNoSuchMethodException e) { var method = MethodResolver.ResolveExtensionMethod( clazz, methodName, paramTypes, true, allowEventBeanType, allowEventBeanType); if (method == null) { throw Convert(clazz, methodName, paramTypes, e, false); } return method; } }
public static EnumValue ResolveIdentAsEnum( string constant, ImportServiceCompileTime importService, ExtensionClass extensionClass, bool isAnnotation) { var lastDotIndex = constant.LastIndexOf('.'); if (lastDotIndex == -1) { return null; } var className = constant.Substring(0, lastDotIndex); var constName = constant.Substring(lastDotIndex + 1); // un-escape className = Unescape(className); constName = Unescape(constName); Type clazz; try { clazz = importService.ResolveClass(className, isAnnotation, extensionClass); } catch (ImportException) { return null; } var field = clazz.GetField(constName); if (field == null) { return null; } if (field.IsPublic && field.IsStatic) { return new EnumValue(clazz, field); } return null; }
public static void Method2 <TValue, TException>(this ExtensionClass <TValue> i, Action <ExtensionClass <TValue>, TException> a) where TException : Exception { }
public static void Method3 <TException>(this ExtensionClass i, TException ex) where TException : Exception { }
public static void Method2 <TException>(this ExtensionClass i, Action <ExtensionClass, TException> a) where TException : Exception { }
public static void Method2 <TValue>(this ExtensionClass <TValue> i, Action <ExtensionClass <TValue>, Exception> a) { }
public static void Method2(this ExtensionClass i, Action <ExtensionClass, Exception> a) { }
private static VariableMetaData GetTypeInfo( string variableName, string variableModuleName, NameAccessModifier variableVisibility, string optionalContextName, NameAccessModifier? optionalContextVisibility, string optionalContextModule, ClassIdentifierWArray variableTypeWArray, bool preconfigured, bool constant, bool compileTimeConstant, object valueAsProvided, ImportService importService, ExtensionClass extensionClass, EventBeanTypedEventFactory eventBeanTypedEventFactory, EventTypeRepositoryImpl eventTypeRepositoryPreconfigured, BeanEventTypeFactory beanEventTypeFactory) { // Determine the variable type var primitiveType = TypeHelper.GetPrimitiveTypeForName(variableTypeWArray.ClassIdentifier); var type = TypeHelper.GetTypeForSimpleName(variableTypeWArray.ClassIdentifier).GetBoxedType(); Type arrayType = null; EventType eventType = null; if (type == null) { if (variableTypeWArray.ClassIdentifier.Equals("object", StringComparison.InvariantCultureIgnoreCase)) { type = TypeHelper.GetArrayType(typeof(object), variableTypeWArray.ArrayDimensions); } if (type == null) { eventType = eventTypeRepositoryPreconfigured.GetTypeByName(variableTypeWArray.ClassIdentifier); if (eventType != null) { type = eventType.UnderlyingType; } } ImportException lastException = null; if (type == null) { try { type = importService.ResolveClass(variableTypeWArray.ClassIdentifier, false, extensionClass); type = TypeHelper.GetArrayType(type, variableTypeWArray.ArrayDimensions); } catch (ImportException e) { Log.Debug("Not found '" + type + "': " + e.Message, e); lastException = e; // expected } } if (type == null) { throw new VariableTypeException( "Cannot create variable '" + variableName + "', type '" + variableTypeWArray.ClassIdentifier + "' is not a recognized type", lastException); } if (variableTypeWArray.ArrayDimensions > 0 && eventType != null) { throw new VariableTypeException( "Cannot create variable '" + variableName + "', type '" + variableTypeWArray.ClassIdentifier + "' cannot be declared as an array type as it is an event type", lastException); } } else { if (variableTypeWArray.ArrayDimensions > 0) { if (variableTypeWArray.IsArrayOfPrimitive) { if (primitiveType == null) { throw new VariableTypeException( "Cannot create variable '" + variableName + "', type '" + variableTypeWArray.ClassIdentifier + "' is not a primitive type"); } arrayType = TypeHelper.GetArrayType(primitiveType, variableTypeWArray.ArrayDimensions); } else { arrayType = TypeHelper.GetArrayType(type, variableTypeWArray.ArrayDimensions); } } } if (eventType == null && !type.IsBuiltinDataType() && type != typeof(object) && !type.IsArray && !type.IsEnum) { if (variableTypeWArray.ArrayDimensions > 0) { throw new VariableTypeException( "Cannot create variable '" + variableName + "', type '" + variableTypeWArray.ClassIdentifier + "' cannot be declared as an array, only scalar types can be array"); } eventType = beanEventTypeFactory.GetCreateBeanType(type, false); } if (arrayType != null) { type = arrayType; } var coerced = GetCoercedValue(valueAsProvided, eventType, variableName, type, eventBeanTypedEventFactory); return new VariableMetaData( variableName, variableModuleName, variableVisibility, optionalContextName, optionalContextVisibility, optionalContextModule, type, eventType, preconfigured, constant, compileTimeConstant, coerced, true); }
public static int MultiplicationNumber(this ExtensionClass multiplication, int Number1, int Number2) { return(Number1 * Number2); }
/// <summary> /// 为DataGridView启用双缓存 /// </summary> /// <param name="gridView">DataGridView对象</param> /// <param name="setting">是否启用双缓存,假如为true则启用</param> public static void SetDoubleBuffered(this DataGridView gridView, bool setting) { ExtensionClass.SetDoubleBuffered <DataGridView>(gridView, setting); }
public Parameters GenerateParameters(CodeFileCSharp input, Settings pluginSettings, IMetadataReader metadataReader, ILogger logger, IFileGroup <CodeFileCSharp, GroupItemDetails> fileGroup = null) { var result = new Parameters(); var ignoreProperties = pluginSettings.IgnorePropertyNames != null && pluginSettings.IgnorePropertyNames.Length > 0 ? new HashSet <string>(pluginSettings.IgnorePropertyNames) : new HashSet <string>(); var typesToFold = pluginSettings.TypesToUnfold != null && pluginSettings.TypesToUnfold.Length > 0 ? new HashSet <string>(pluginSettings.TypesToUnfold) : new HashSet <string>(); INamedTypeSymbol requiredType = null; if (!string.IsNullOrEmpty(pluginSettings.RequiredClassBaseType)) { requiredType = input.SemanticModel.Compilation.GetTypeByMetadataName(pluginSettings.RequiredClassBaseType); if (requiredType == null) { throw new InvalidOperationException($"Cannot resolve required base type {pluginSettings.RequiredClassBaseType} from compilation."); } } foreach (var classDeclaration in input.SyntaxTree.GetRoot().DescendantNodes().OfType <ClassDeclarationSyntax>()) { if (requiredType != null && classDeclaration.BaseList != null) { bool hasRequiredType = false; foreach (var baseType in classDeclaration.BaseList.Types) { var typeInfo = input.SemanticModel.GetTypeInfo(baseType.Type); if (typeInfo.Type.InheritsFromOrImplementsOrEqualsIgnoringConstruction(requiredType)) { hasRequiredType = true; break; } } if (!hasRequiredType) { continue; } } var extensionClass = new ExtensionClass(); var declaredSymbol = input.SemanticModel.GetDeclaredSymbol(classDeclaration); if (declaredSymbol.IsAbstract) { continue; } extensionClass.ExtensionClassName = $"{declaredSymbol.Name}Extensions"; extensionClass.RelatedClassSymbol = declaredSymbol; extensionClass.RelatedClassDeclaration = classDeclaration; var props = declaredSymbol.GetAllSymbols <IPropertySymbol>(SymbolKind.Property, Accessibility.Public) .Where(p => !p.IsStatic) .ToArray(); if (props.Length > 0) { extensionClass.Members.AddRange(this.GetExtensionMembers(props, declaredSymbol, typesToFold, requiredType, ignoreProperties, pluginSettings)); ////var outputFile = (CodeFileCSharp)this.outputStream.CreateCodeFile($"{declaredSymbol.Name}Extensions.cs"); } extensionClass.Include = !typesToFold.Contains(declaredSymbol.MetadataName) && extensionClass.Members.Any(m => m.Include); result.ExtensionClasses.Add(extensionClass); } return(result); }