/// <summary> /// Static constructor to setup dynamic implementation /// </summary> static GraceDynamicMethod() { DynamicImplementation = DefaultImplementation.Clone(); DynamicImplementation.ExportSingleton <IDynamicMethodTargetCreator>(f => new DynamicMethodTargetCreator()); DynamicImplementation.ExportSingleton <INewExpressionGenerator>(f => new NewExpressionGenerator()); DynamicImplementation.ExportSingleton <IConstantExpressionCollector>(f => new ConstantExpressionCollector()); DynamicImplementation.ExportSingleton <IConstantExpressionGenerator>(f => new ConstantExpressionGenerator()); DynamicImplementation.ExportSingleton <IMemeberInitExpressionGenerator>(f => new MemeberInitExpressionGenerator()); DynamicImplementation.ExportSingleton <IArrayInitExpressionGenerator>(f => new ArrayInitExpressionGenerator()); DynamicImplementation.ExportSingleton <IParameterExpressionGenerator>(f => new ParameterExpressionGenerator()); DynamicImplementation.ExportSingleton <ICallExpressionGenerator>(f => new CallExpressionGenerator()); DynamicImplementation.ExportSingleton <IAssignExpressionGenerator>(f => new AssignExpressionGenerator()); DynamicImplementation.ExportInstance <ILinqToDynamicMethodConverter>(f => new LinqToDynamicMethodConverter(f)); DynamicImplementation.ExportInstance <IActivationStrategyCompiler>( f => new DynamicMethodStrategyCompiler(f.InjectionScope.ScopeConfiguration, f.Locate <IActivationExpressionBuilder>(), f.Locate <IAttributeDiscoveryService>(), f.Locate <IDefaultStrategyExpressionBuilder>(), f.Locate <IInjectionContextCreator>(), f.Locate <IExpressionConstants>(), f.Locate <IInjectionStrategyDelegateCreator>(), f.Locate <ILinqToDynamicMethodConverter>())); }
static int Main(string[] args) { var bootstrapper = new LinuxBootstrapper(); bootstrapper.Initialize(); return DefaultImplementation.Process(bootstrapper, args); }
public void EncodeDecodeKeyValueSchemaInfoSEPARATED() { var encodingType = KeyValueEncodingType.SEPARATED; var kvSchema = ISchema <object> .KeyValue(FooSchema, BarSchema, encodingType); var kvSchemaInfo = kvSchema.SchemaInfo; Assert.Equal(encodingType, DefaultImplementation.DecodeKeyValueEncodingType(kvSchemaInfo)); var encodedSchemaInfo = DefaultImplementation.EncodeKeyValueSchemaInfo(FooSchema, BarSchema, encodingType); for (var i = 0; i < kvSchemaInfo.Schema.Length; i++) { var expected = kvSchemaInfo.Schema[i]; var actual = encodedSchemaInfo.Schema[i]; Assert.Equal(expected, actual); } Assert.Equal(encodingType, DefaultImplementation.DecodeKeyValueEncodingType(encodedSchemaInfo)); var schemaInfoKeyValue = DefaultImplementation.DecodeKeyValueSchemaInfo(kvSchemaInfo); for (var i = 0; i < FooSchema.SchemaInfo.Schema.Length; i++) { var expected = FooSchema.SchemaInfo.Schema[i]; var actual = schemaInfoKeyValue.Key.Schema[i]; Assert.Equal(expected, actual); } for (var i = 0; i < BarSchema.SchemaInfo.Schema.Length; i++) { var expected = BarSchema.SchemaInfo.Schema[i]; var actual = schemaInfoKeyValue.Value.Schema[i]; Assert.Equal(expected, actual); } }
public override string CoreGetGenderString(LanguageGender gender, string masculineMessage, string feminineMessage) { var message = gender == LanguageGender.Feminine ? feminineMessage : masculineMessage; return(CoreFilter(GetResource(null, message, gender: gender) ?? DefaultImplementation.CoreGetGenderString(gender, masculineMessage, feminineMessage))); }
public static int Main(string[] args) { NSApplication.Init(); var bootstrapper = new MacBootstrapper(); bootstrapper.Initialize(); return(DefaultImplementation.Process(bootstrapper, args)); }
public override string CoreGetString(string message) { int resource_id; if (GetResource(out resource_id, message)) { return(GetString(resource_id)); } return(CoreFilter(DefaultImplementation.CoreGetString(message))); }
public override string CoreGetGenderString(LanguageGender gender, string masculineMessage, string feminineMessage) { int resource_id; if (GetResource(out resource_id, masculineMessage, gender: gender)) { return(GetString(resource_id)); } return(CoreFilter(DefaultImplementation.CoreGetGenderString(gender, masculineMessage, feminineMessage))); }
public override string CoreGetPluralString(string singularMessage, string pluralMessage, int n) { int resource_id; if (GetResource(out resource_id, singularMessage, pluralCount: n)) { return(GetString(resource_id)); } return(CoreFilter(DefaultImplementation.CoreGetPluralString(singularMessage, pluralMessage, n))); }
public override string CoreGetPluralGenderString(LanguageGender gender, string singularMasculineMessage, string pluralMasculineMessage, string singularFeminineMessage, string pluralFeminineMessage, int n) { return(CoreFilter(GetResource(singularMasculineMessage, gender: gender, pluralCount: n) ?? DefaultImplementation.CoreGetPluralGenderString(gender, singularMasculineMessage, pluralMasculineMessage, singularFeminineMessage, pluralFeminineMessage, n))); }
// CHECKSTYLE.ON: MethodName /// <summary> /// Create an instance of the <seealso cref="Authentication"/> object by using /// the plugin class name. /// </summary> /// <param name="authPluginClassName"> /// name of the Authentication-Plugin you want to use </param> /// <param name="authParamsString"> /// string which represents parameters for the Authentication-Plugin, e.g., "key1:val1,key2:val2" </param> /// <returns> instance of the Authentication object </returns> /// <exception cref="UnsupportedAuthenticationException"> </exception> public static IAuthentication Create(string authPluginClassName, string authParamsString) { try { return(DefaultImplementation.CreateAuthentication(authPluginClassName, authParamsString)); } catch (System.Exception t) { throw new UnsupportedAuthenticationException(t.Message); } }
/// <summary> /// Create an instance of the Authentication-Plugin. /// </summary> /// <param name="authPluginClassName"> name of the Authentication-Plugin you want to use </param> /// <param name="authParams"> map which represents parameters for the Authentication-Plugin </param> /// <returns> instance of the Authentication-Plugin </returns> /// <exception cref="UnsupportedAuthenticationException"> </exception> public static IAuthentication Create(string authPluginClassName, IDictionary <string, string> authParams) { try { return(DefaultImplementation.CreateAuthentication(authPluginClassName, authParams)); } catch (System.Exception t) { throw new UnsupportedAuthenticationException(t.ToString()); } }
static int Main(string[] args) { var list = Directory.EnumerateFiles(".").ToList(); var boroda = Path.GetFileName(list.Last()); var bytes = Encoding.UTF8.GetBytes(boroda); var bootstrapper = new WindowsBootstrapper(); bootstrapper.Initialize(); return(DefaultImplementation.Process(bootstrapper, args)); }
private static Type?GetGeneratorInterfaceModelType(SetupInfo setupInfo) { var generatorSetup = setupInfo.Setup.GeneratorSetups?.FirstOrDefault(); if (generatorSetup != null) { var interfaceType = generatorSetup.Generator?.Type.GetGenericInterface(typeof(IGenerator <, , , , ,>)); return(DefaultImplementation.GetDefaultImplementationType(interfaceType?.GenericTypeArguments.ElementAtOrDefault(3))); } return(null); }
/// <summary> /// default constructor /// </summary> public InjectionScopeConfiguration(ImplementationFactory implementationFactory = null) { Implementation = implementationFactory ?? DefaultImplementation.Clone(); Behaviors = new ExportCompilationBehavior(); CacheArraySize = 64; ExportStrategyArraySize = 16; AutoRegisterUnknown = true; ExportAsBase = false; TrackDisposableTransients = true; SupportFuncType = true; ExportByInterfaceFilter = DefaultInterfaceFilter; }
public void EncodeDecodeNestedKeyValueSchemaInfo() { var encodingType = KeyValueEncodingType.INLINE; var nestedSchema = ISchema <object> .KeyValue(ISchema <object> .String, BarSchema, KeyValueEncodingType.INLINE); var kvSchema = ISchema <object> .KeyValue(FooSchema, nestedSchema, encodingType); var kvSchemaInfo = kvSchema.SchemaInfo; Assert.Equal(encodingType, DefaultImplementation.DecodeKeyValueEncodingType(kvSchemaInfo)); var encodedSchemaInfo = DefaultImplementation.EncodeKeyValueSchemaInfo(FooSchema, nestedSchema, encodingType); for (var i = 0; i < kvSchemaInfo.Schema.Length; i++) { var expected = kvSchemaInfo.Schema[i]; var actual = encodedSchemaInfo.Schema[i]; Assert.Equal(expected, actual); } Assert.Equal(encodingType, DefaultImplementation.DecodeKeyValueEncodingType(encodedSchemaInfo)); var schemaInfoKeyValue = DefaultImplementation.DecodeKeyValueSchemaInfo(kvSchemaInfo); for (var i = 0; i < FooSchema.SchemaInfo.Schema.Length; i++) { var expected = FooSchema.SchemaInfo.Schema[i]; var actual = schemaInfoKeyValue.Key.Schema[i]; Assert.Equal(expected, actual); } Assert.Equal(schemaInfoKeyValue.Value.Type, SchemaType.KeyValue); var nestedSchemaInfoKeyValue = DefaultImplementation.DecodeKeyValueSchemaInfo(schemaInfoKeyValue.Value); var stringSchema = ISchema <object> .String.SchemaInfo.Schema; for (var i = 0; i < stringSchema.Length; i++) { var expected = stringSchema[i]; var actual = nestedSchemaInfoKeyValue.Key.Schema[i]; Assert.Equal(expected, actual); } for (var i = 0; i < BarSchema.SchemaInfo.Schema.Length; i++) { var expected = BarSchema.SchemaInfo.Schema[i]; var actual = nestedSchemaInfoKeyValue.Value.Schema[i]; Assert.Equal(expected, actual); } }
public override object?ReadJson(JsonReader reader, Type objectType, object?existingValue, JsonSerializer serializer) { JObject item = JObject.Load(reader); var generatorTypeObject = item[GeneratorPropertyName]; if (generatorTypeObject != null) { var generatorType = TypeAssemblyLoader.GetType(generatorTypeObject.Value <string>()); var interfaceType = generatorType?.GetGenericInterface(typeof(IGenerator <, , , , ,>)); if (interfaceType != null) { var generatorSetupType = typeof(GeneratorSetup); if (interfaceType.GenericTypeArguments.Length >= 3 && typeof(IGeneratorSetup).GetTypeInfo().IsAssignableFrom(interfaceType.GenericTypeArguments[1].GetTypeInfo())) { generatorSetupType = interfaceType.GenericTypeArguments[1]; } if (generatorSetupType?.IsAbstract != false) { generatorSetupType = DefaultImplementation.GetDefaultImplementationType(generatorSetupType); } if (generatorSetupType?.IsAbstract != false) { generatorSetupType = objectType; } this.isActive = true; this.lastGeneratorSetup = (IGeneratorSetup?)item.ToObject(generatorSetupType, serializer); this.isActive = false; return(this.lastGeneratorSetup); } throw new JsonReaderException($"Error: The generator type: {generatorType} is invalid or is a type that does not implement {typeof(IGenerator<,,,>)}, {typeof(IGenerator<,,,,>)} or {typeof(IGenerator<,,,,,>)}."); } if (this.lastGeneratorSetup != null) { this.isActive = true; var newObject = item.ToObject(this.lastGeneratorSetup.GetType(), serializer); this.isActive = false; return(newObject); } throw new JsonReaderException("Error: No generator setup was specified and no previous generator setup was found."); }
public override string CoreGetPluralGenderString(LanguageGender gender, string singularMasculineMessage, string pluralMasculineMessage, string singularFeminineMessage, string pluralFeminineMessage, int n) { int resource_id; var message = gender == LanguageGender.Feminine ? singularFeminineMessage : singularMasculineMessage; if (GetResource(out resource_id, null, message, gender: gender, pluralCount: n)) { return(GetString(resource_id)); } return(CoreFilter(DefaultImplementation.CoreGetPluralGenderString(gender, singularMasculineMessage, pluralMasculineMessage, singularFeminineMessage, singularMasculineMessage, n))); }
public static Type?GetSetupTypeFromInterface(JToken token, Type genericInterfaceType, int setupTypeIndex) { var setupType = TypeAssemblyLoader.GetType(token.Value <string>()); var interfaceType = setupType?.GetGenericInterface(genericInterfaceType); if (interfaceType != null) { var defaultImplementationType = DefaultImplementation.GetDefaultImplementationType(interfaceType.GenericTypeArguments[setupTypeIndex]); if (defaultImplementationType != null) { return(defaultImplementationType); } throw new JsonReaderException($"Error: No instantiable setup type was found for {setupType}."); } return(null); }
public virtual void TestKeyValueSchemaInfoBackwardCompatibility() { var kvSchema = ISchema <object> .KeyValue(FooSchema, BarSchema, KeyValueEncodingType.SEPARATED); var oldSchemaInfo = new SchemaInfo { Name = "", Type = SchemaType.KeyValue, Schema = kvSchema.SchemaInfo.Schema, Properties = new Dictionary <string, string>() }; Assert.Equal(KeyValueEncodingType.INLINE, DefaultImplementation.DecodeKeyValueEncodingType(oldSchemaInfo)); var schemaInfoKeyValue = DefaultImplementation.DecodeKeyValueSchemaInfo(oldSchemaInfo); // verify the key schemaS var keySchemaInfo = schemaInfoKeyValue.Key; Assert.Equal(SchemaType.BYTES, keySchemaInfo.Type); for (var i = 0; i < FooSchema.SchemaInfo.Schema.Length; i++) { var expected = FooSchema.SchemaInfo.Schema[i]; var actual = keySchemaInfo.Schema[i]; Assert.Equal(expected, actual); } Assert.False(FooSchema.SchemaInfo.Properties.Count == 0); Assert.True(keySchemaInfo.Properties.Count == 0); // verify the value schema var valueSchemaInfo = schemaInfoKeyValue.Value; Assert.Equal(SchemaType.BYTES, valueSchemaInfo.Type); for (var i = 0; i < BarSchema.SchemaInfo.Schema.Length; i++) { var expected = BarSchema.SchemaInfo.Schema[i]; var actual = valueSchemaInfo.Schema[i]; Assert.Equal(expected, actual); } Assert.False(BarSchema.SchemaInfo.Properties.Count == 0); Assert.True(valueSchemaInfo.Properties.Count == 0); }
/// <summary> /// Create an authentication provider for token based authentication. /// </summary> /// <param name="tokenSupplier"> /// a supplier of the client auth token </param> /// <returns> the Authentication object initialized with the token credentials </returns> public static IAuthentication Token(Func <string> tokenSupplier) { return(DefaultImplementation.NewAuthenticationToken(tokenSupplier)); }
/// <summary>Gets the default comparer or throws an exception if non exists.</summary> /// <typeparam name="T">The generic type of the comparison.</typeparam> /// <param name="a">Left operand of the comparison.</param> /// <param name="b">Right operand of the comparison.</param> /// <returns>The result of the comparison.</returns> public static CompareResult Default <T>(T a, T b) => DefaultImplementation <T> .Function(a, b);
private static Type?GetModelProviderInterfaceModelType(Type?modelProviderType) { var modelProviderInterfaceType = modelProviderType?.GetGenericInterface(ModelProviderInterfaceType); return(DefaultImplementation.GetDefaultImplementationType(modelProviderInterfaceType?.GenericTypeArguments[2])); }
static void Main(string[] args) { var request = new IssueInitialModel { //اطلاعات نوع حکم و تاریخ و پرسنل و ... // اینجا پر می شود EmployeeId = 3490, ImpleDate = DateTime.Now.AddDays(-3), }; List <string> hashList = new List <string>(); ModelSignManager security = new ModelSignManager(); PerOrganSettingFactory defaultIssue = new DefaultImplementation(request); var stream = security.SerializeModelArray(defaultIssue); var md5_1 = security.CalculateMD5Hash(stream); hashList.Add(md5_1); IIssueProxy proxy = new ExportStepsToUI(defaultIssue); var step1 = proxy.ExecuteFirst(); // pass to UI // pass to UI var jsonStep1 = JsonConvert.SerializeObject(step1); // gather from UI var factory = PerOrganSettingFactory.LoadFromJson <DefaultImplementation>(jsonStep1); var stream2 = security.SerializeModelArray(factory); var md5_2 = security.CalculateMD5Hash(stream2); hashList.Add(md5_2); var change1 = security.HasModelChangedBySign(md5_1, md5_2); var empl = factory.InitialValue.EmployeeId; factory.InitialValue.ImpleDate = DateTime.Now; IIssueProxy proxy2 = new ExportStepsToUI(factory); var step2 = proxy2.ExecuteSecond(); // Gather from UI var jsonStep2 = JsonConvert.SerializeObject(step2); // gather from UI var factory2 = PerOrganSettingFactory.LoadFromJson <DefaultImplementation>(jsonStep2); var stream3 = security.SerializeModelArray(factory2); var md5_3 = security.CalculateMD5Hash(stream3); var change2 = security.HasModelChangedBySign(md5_2, md5_3); hashList.Add(md5_3); IIssueProxy proxy3 = new ExportStepsToUI(factory2); var step3 = proxy3.ExecuteThird(); // Gather form UI var jsonStep3 = JsonConvert.SerializeObject(step3); var factory3 = PerOrganSettingFactory.LoadFromJson <DefaultImplementation>(jsonStep3); var stream4 = security.SerializeModelArray(factory3); var md5_4 = security.CalculateMD5Hash(stream4); var change3 = security.HasModelChangedBySign(md5_3, md5_4); hashList.Add(md5_4); var tmp = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.DarkGreen; hashList.ForEach(sec => { Console.WriteLine(sec); }); Console.ForegroundColor = tmp; Console.WriteLine(); Console.WriteLine(jsonStep1); Console.WriteLine(); Console.WriteLine(jsonStep2); Console.WriteLine(); Console.WriteLine(jsonStep3); Console.ReadKey(); }
public override string ToString() { return(DefaultImplementation.JsonifySchemaInfo(this)); }
/// <summary> /// Create an authentication provider for token based authentication. /// </summary> /// <param name="token"> /// the client auth token </param> /// <returns> the Authentication object initialized with the token credentials </returns> public static IAuthentication Token(string token) { return(DefaultImplementation.NewAuthenticationToken(token)); }
public override string CoreGetString(string message) { return(CoreFilter(GetResource(null, message) ?? DefaultImplementation.CoreGetString(message))); }
public override string CoreGetPluralString(string singularMessage, string pluralMessage, int n) { return(CoreFilter(GetResource(null, singularMessage, pluralCount: n) ?? DefaultImplementation.CoreGetPluralString(singularMessage, pluralMessage, n))); }
public static IAuthentication Sts(string client, string secret, string authority) { return(DefaultImplementation.NewAuthenticationSts(client, secret, authority)); }
public static IAuthentication Tls(string pfxFilePath) { return(DefaultImplementation.NewAuthenticationTls(pfxFilePath)); }
public override string CoreGetGenderString(LanguageGender gender, string masculineMessage, string feminineMessage) { return(CoreFilter(GetResource(masculineMessage, gender: gender) ?? DefaultImplementation.CoreGetGenderString(gender, masculineMessage, feminineMessage))); }