public BuildInfo <T> Mapping <TR>(Func <TR, object> func) { MethodInformation.Delegates.Add(func); CurrentMethod.Mapping = new MappingAttribute(typeof(TR)); CurrentMethod = BuilderHelper.CompleteMethodInfo(typeof(T), CurrentMethod); MethodInformations.Add(CurrentMethod); return(this); }
protected static void FillBuilderHelper(TypeDefinition type, PropertyDefinition property, BuilderHelper builderHelper) { builderHelper.IsArray = property.PropertyType.IsArray; builderHelper.IsComplexType = IsComplexType(property.PropertyType.Resolve()); FillBuilderHelperXml(type, property, builderHelper); FillBuilderHelperData(type, property, builderHelper); }
private void AnalyseBuilder(SymbolAnalysisContext context, INamedTypeSymbol builderSymbol, INamedTypeSymbol builderForSymbol) { IList <IFieldSymbol> fieldsWithoutSetterMethods = BuilderHelper.FindFieldsWithoutSetterMethodInBuilder(builderSymbol, builderForSymbol); foreach (IFieldSymbol fieldWithoutSetterMethod in fieldsWithoutSetterMethods) { context.ReportFieldHasNoSetterInBuilder(fieldWithoutSetterMethod); } }
public void Build(System.Collections.Generic.List <string> scenesToBuild, UnityEditor.BuildTarget buildTarget, UnityEditor.BuildOptions buildOptions) { Console.WriteLine("ios PreBuild"); BuilderHelper.BootSceneFilename = "Assets/Scenes/Boot/Boot.unity"; BuilderHelper.BuildInsidePlayer(ref scenesToBuild, ref buildTarget, ref buildOptions, this); InJoy.UnityBuildSystem.AutoBuild.UnityBuildPlayer(scenesToBuild, buildTarget, buildOptions); AssetBundlesFtp.GenerateIndexSizeMapToFile("assetBundlesSizeFile.txt"); Console.WriteLine("ios PostBuild"); }
/// <summary> /// Sets the minimum log level to show to the user /// </summary> /// <returns></returns> public static IApplicationBuilder UseLogger(this IApplicationBuilder builder, LoggerOptions options) { builder.BuildActionsCoordinator.AddAction(DefaultBuildActions.LoggerBuildAction((container) => { BuilderHelper.RegisterLoggers(options, container); })); return(builder); }
private static Function ConvolutionWithActivation(Variable features, DeviceDescriptor device, ConvolutionConfigurationModel configuration) { var convFunction = Convolution(features, device, configuration); var convWithActivationFunction = BuilderHelper.GetActivationFunction(configuration.ActivationFunction, convFunction); return(convWithActivationFunction); }
public void Cmd_InstantiateBuilding(NetworkHash128 prefabId, int builderId, Vector3 position) { GameObject go = Instantiate(PrefabIdHelper.IdGoBuilding[prefabId], position, Quaternion.identity, _world.transform); Attackable building = go.GetComponent <Attackable>(); building.CreatorId = BuilderId; building.Allegiance = BuilderHelper.GetBuilderById(BuilderId).Allegiance; building.IsActive = true; NetworkServer.Spawn(go); }
Ensure_When_We_Configure_An_Authorizer_With_A_Post_Build_Action_The_Resolver_Returns_An_Authorizer_That_Has_Had_The_Action_Executed_Against_It () { var conf = BuilderHelper.BuildConfigurationObject(); conf.Register(a => a.Method <TestCodeClass>(c => c.DoSomething(default(string))).AuthorizedBy <HasRoles>(r => r.AuthorizedRoles = new[] { "Test" })); var resolver = BuildAuthorizerResolver(conf.ActivityRegistrations); var authorizer = (HasRoles)resolver.GetAuthorizers(new MethodActivity(typeof(TestCodeClass).GetMethod("DoSomething"))).First(); Assert.That(authorizer.AuthorizedRoles.First(), Is.EqualTo("Test")); }
Ensure_When_We_Register_The_Method_Of_A_Base_Class_We_Can_Resolve_The_Activity_With_An_Expression_Using_The_Child_Class () { var conf = BuilderHelper.BuildConfigurationObject(); conf.Register(a => a.Method <TestCodeClass>(c => c.DoSomething(default(string))).As <TestActivity>().AuthorizedBy <UnauthorizedAuthorizer>()); var resolver = BuildActivityResolver(conf.ActivityRegistrations); var act = resolver.GetActivity <TestChildClass>(c => c.DoSomething("test")); Assert.That(act is TestActivity); }
Ensure_If_We_Provide_A_Specific_Name_For_An_Activity_Registered_By_Method_The_Name_Is_Correctly_Set_On_The_Resolved_Activity () { var conf = BuilderHelper.BuildConfigurationObject(); conf.Register(a => a.Method <TestCodeClass>(c => c.DoSomething(default(string))).Name("TestActivity").AuthorizedBy <AllowAnonymous>()); var resolver = BuildActivityResolver(conf.ActivityRegistrations); var activity = resolver.GetActivity <TestCodeClass>(c => c.DoSomething("test")); Assert.That(activity.Name, Is.EqualTo("TestActivity")); }
Ensure_When_We_Register_A_Method_As_A_Specific_Activity_Type_Ensure_When_We_Resolve_By_Lamdba_Expression_The_Method_Parameters_Are_Used_In_The_Type_Constructor () { var conf = BuilderHelper.BuildConfigurationObject(); conf.Register(a => a.Method <TestCodeClass>(c => c.DoSomething(default(string))).As <TestActivity>().AuthorizedBy <UnauthorizedAuthorizer>()); var resolver = BuildActivityResolver(conf.ActivityRegistrations); var act = (TestActivity)resolver.GetActivity <TestCodeClass>(c => c.DoSomething("test")); Assert.That(act.Id, Is.EqualTo("test")); }
new private void Start() { base.Start(); attack = new Attack(0, 1.0f, this, 10, (Targetable attackable) => TargetingFunction.IsEnemy(this, attackable)) { Effects = new List <Effect> { new FaithKill(new ResourceFaith(1), BuilderHelper.GetBuilderById(this.CreatorId), TargetingFunction.IsUnit) } }; Skills = new[] { attack }; }
public void Ensure_We_Can_Resolve_An_Activity_By_Expression_With_A_Variable() { var conf = BuilderHelper.BuildConfigurationObject(); conf.Register(a => a.Method <TestCodeClass>(c => c.DoSomething(default(string))).As <TestActivity>().AuthorizedBy <UnauthorizedAuthorizer>()); var resolver = BuildActivityResolver(conf.ActivityRegistrations); var test = "test"; var activity = (TestActivity)resolver.GetActivity <TestCodeClass>(c => c.DoSomething(test)); Assert.That(activity.Id, Is.EqualTo("test")); }
public static void Analyze(IDbConnection connection) { if (!connection.ToString().Contains("System.Data.SqlClient")) { throw new InvalidOperationException("Only Sql Server is supported."); } BuilderHelper.BuildSchemas(connection); BuilderHelper.BuildTables(connection); BuilderHelper.BuildTableColumns(connection); BuilderHelper.BuildViewColumns(connection); BuilderHelper.BuildRelation(connection); }
virtual public object BuildItem(PluginItemMetadata itemData, PluginRuntime plugin) { BuilderHelper.CheckParameter("ClassName", itemData); BuilderHelper.CheckParameter("Caption", itemData); BuilderHelper.CheckParameter("Sort", itemData); string restrictionGroup; // optional if (itemData.Attributes.TryGetValue("RestrictionGroup", out restrictionGroup)) { ServiceRegistration.Get <IUserManagement>().RegisterRestrictionGroup(restrictionGroup); } return(_constructor(plugin.GetPluginType(itemData.Attributes["ClassName"]), itemData.Attributes["Caption"], itemData.Attributes["Sort"], restrictionGroup, itemData.Id)); }
private static Function Dense(Variable input, int outputDim, DeviceDescriptor device, ActivationFunction activationFunction, string outputName) { if (input.Shape.Rank != 1) { var newDim = input.Shape.Dimensions.Aggregate((d1, d2) => d1 * d2); input = CNTKLib.Reshape(input, new [] { newDim }); } var fullyConnected = FullyConnectedLinearLayer(input, outputDim, device, outputName); return(BuilderHelper.GetActivationFunction(activationFunction, fullyConnected)); }
Ensure_That_If_A_Method_Activity_Has_Been_Registered_With_The_Allow_Anonymous_Authorizer_That_Is_The_Only_One_The_Authorizer_Resolver_Returns () { var conf = BuilderHelper.BuildConfigurationObject(); conf.Register(a => a.Method <TestCodeClass>(c => c.DoSomething(default(string))).AuthorizedBy <UnauthorizedAuthorizer>()); conf.Register(a => a.Method <TestCodeClass>(c => c.DoSomething(default(string))).AuthorizedBy <AllowAnonymous>()); var resolver = BuildAuthorizerResolver(conf.ActivityRegistrations); var authorizers = resolver.GetAuthorizers(new MethodActivity(typeof(TestCodeClass).GetMethod("DoSomething"))); Assert.That(authorizers.Count, Is.EqualTo(1)); }
// At the moment, we simply use an InstanceBuilder here. In the future, we could provide the option to // give a set of supported file extensions in the player builder item registration, which can be evaluated before // requesting the player builder -> lazy load the player builders on request public object BuildItem(PluginItemMetadata itemData, PluginRuntime plugin) { BuilderHelper.CheckParameter("ClassName", itemData); int priority = 0; string prioString; if (itemData.Attributes.TryGetValue("Priority", out prioString)) { int.TryParse(prioString, out priority); } return(new PlayerBuilderWrapper(itemData.Id, plugin.InstantiatePluginObject(itemData.Attributes["ClassName"]) as IPlayerBuilder, priority)); }
public void Ensure_That_The_Failure_Manager_Assigns_A_404_Result_To_An_Unauthorizer_Activity_Registered_By_Name_With_A_404_Handler() { var conf = BuilderHelper.BuildConfigurationBuilder(); conf.Register(a => a.Name("Test").AuthorizedBy <UnauthorizedAuthorizer>().HandleFailureWith <HttpNotFoundResult>()); var context = FilterContextHelper.ContextFromExpression <TestController>(c => c.ControllerAction("test")); var manager = new AuthorizationFailureManager(conf.ActivityRegistrations); manager.HandleFailedAuthorization(new NamedActivity("Test"), context); Assert.That(context.Result.GetType(), Is.EqualTo(typeof(HttpNotFoundResult))); }
Ensure_That_If_Two_Methods_Are_Registered_To_The_Same_Activity_With_The_Same_Authorizer_And_An_ActivityType_The_Authorizer_Is_Returned_Correctly_By_The_Resolver () { var builder = BuilderHelper.BuildConfigurationObject(); builder.RegisterEach <TestCodeClass>(c => c.DoSomething(""), c => c.DoSomething2("")).With(a => a.As <TestActivity>().AuthorizedBy <UnauthorizedAuthorizer>()); var resolver = BuildAuthorizerResolver(builder.ActivityRegistrations); var authorizer1 = resolver.GetAuthorizers <TestCodeClass>(c => c.DoSomething("")).First(); var authorizer2 = resolver.GetAuthorizers <TestCodeClass>(c => c.DoSomething2("")).First(); Assert.That(authorizer1.GetType(), Is.EqualTo(typeof(UnauthorizedAuthorizer))); Assert.That(authorizer2.GetType(), Is.EqualTo(typeof(UnauthorizedAuthorizer))); }
public void Ensure_When_We_Register_A_Method_Activity_By_Name_We_Can_Resolve_Is_Authorizer() { var conf = BuilderHelper.BuildConfigurationObject(); conf.Register(a => a.Method <TestCodeClass>(c => c.DoSomething(default(string))).Name("TestActivity").AuthorizedBy <UnauthorizedAuthorizer>()); var resolver = BuildAuthorizerResolver(conf.ActivityRegistrations); var authorizer = resolver.GetAuthorizers(new MethodActivity(typeof(TestCodeClass).GetMethod("DoSomething")) { Name = "TestActivity" }).First(); Assert.That(authorizer is UnauthorizedAuthorizer); }
public override void BuildCode(Builder builder) { base.BuildCode(builder); builder.AppendLine("{0} {1}", this.Type, this.Name); builder.AppendLine("{"); builder.EnterBlock(); if (this.Getter != null) { builder.Append(BuilderHelper.ModifiersToString(this.Getter.Modifiers)); builder.Append("get"); string body = this.Getter.Body.ToString(); if (body.Length == 0) { builder.AppendLine("; "); } else { builder.AppendLine(); builder.AppendLine("{"); builder.EnterBlock(); builder.Append(body); builder.LeaveBlock(); builder.AppendLine("}"); } } if (this.Setter != null) { builder.Append(BuilderHelper.ModifiersToString(this.Setter.Modifiers)); builder.Append("set"); string body = this.Setter.Body.ToString(); if (body.Length == 0) { builder.AppendLine("; "); } else { builder.AppendLine(); builder.AppendLine("{"); builder.EnterBlock(); builder.Append(body); builder.LeaveBlock(); builder.AppendLine("}"); } } builder.LeaveBlock(); builder.AppendLine("}"); }
internal FilterBuilder(BuilderHelper helper) { this.helper = helper; Expressions = new Dictionary <Operation, Func <Expression, Expression, Expression, Expression> > { { Operation.EqualTo, (member, constant, constant2) => Expression.Equal(member, constant) }, { Operation.NotEqualTo, (member, constant, constant2) => Expression.NotEqual(member, constant) }, { Operation.GreaterThan, (member, constant, constant2) => Expression.GreaterThan(member, constant) }, { Operation.GreaterThanOrEqualTo, (member, constant, constant2) => Expression.GreaterThanOrEqual(member, constant) }, { Operation.LessThan, (member, constant, constant2) => Expression.LessThan(member, constant) }, { Operation.LessThanOrEqualTo, (member, constant, constant2) => Expression.LessThanOrEqual(member, constant) }, { Operation.Contains, (member, constant, constant2) => Contains(member, constant) }, { Operation.StartsWith, (member, constant, constant2) => Expression.Call(member, startsWithMethod, constant) }, { Operation.EndsWith, (member, constant, constant2) => Expression.Call(member, endsWithMethod, constant) }, { Operation.Between, (member, constant, constant2) => Between(member, constant, constant2) }, { Operation.In, (member, constant, constant2) => Contains(member, constant) }, { Operation.IsNull, (member, constant, constant2) => Expression.Equal(member, Expression.Constant(null)) }, { Operation.IsNotNull, (member, constant, constant2) => Expression.NotEqual(member, Expression.Constant(null)) }, { Operation.IsEmpty, (member, constant, constant2) => Expression.Equal(member, Expression.Constant(string.Empty)) }, { Operation.IsNotEmpty, (member, constant, constant2) => Expression.NotEqual(member, Expression.Constant(string.Empty)) }, { Operation.IsNullOrWhiteSpace, (member, constant, constant2) => IsNullOrWhiteSpace(member) }, { Operation.IsNotNullNorWhiteSpace, (member, constant, constant2) => IsNotNullNorWhiteSpace(member) } }; }
public void Ensure_We_Can_Resolve_A_Named_Activity_By_Name() { var config = BuilderHelper.BuildConfigurationObject(); var resolver = BuildActivityResolver(new List <ActivityRegistration>() { new ActivityRegistration { ActivityName = "Activity" } }); var activity = resolver.GetActivity("Activity"); Assert.That(activity.Name, Is.EqualTo("Activity")); }
Ensure_When_We_Register_Two_Methods_With_The_Same_As_The_Same_Activity_Type_We_Can_Resolve_Each_Individually () { var conf = BuilderHelper.BuildConfigurationObject(); conf.Register(a => a.Method <TestCodeClass>(c => c.DoSomething(default(string))).As <TestActivity>().AuthorizedBy <UnauthorizedAuthorizer>()); conf.Register(a => a.Method <TestCodeClass2>(c => c.DoSomething(default(string))).As <TestActivity>().AuthorizedBy <UnauthorizedAuthorizer>()); var resolver = BuildActivityResolver(conf.ActivityRegistrations); var act1 = resolver.GetActivity <TestCodeClass>(c => c.DoSomething("test")); var act2 = resolver.GetActivity <TestCodeClass2>(c => c.DoSomething("test")); Assert.That(act1 is TestActivity); Assert.That(act2 is TestActivity); }
void ClickUpgrade(GameObject upgrade) { Builder Creator = NetworkHelper.IsOffline ? BuilderHelper.GetBuilderById(Building.CreatorId) : NetworkHelper.Builder; if (!Creator.CanPayBuilding(upgrade.GetComponent <IBuildingCost>())) { // Proc not enough money message } else { Creator.PayBuilding(upgrade.GetComponent <IBuildingCost>()); GameObject previousBuilding = this.Building.gameObject; InstantiateBuilding(upgrade, Creator, previousBuilding); Destroy(previousBuilding); } }
public void FreezeReference(TableModel table, IEnumerable <TableModel> tables) { ReferenceTable = tables.FirstOrDefault(t => t.Property.Name == _referenceTable.Name); if (ReferenceTable == null) { throw BuilderError.SelectorNotMappedToTable(_referenceTable.Name, _referenceTable.DeclaringType.Name).AsException(); } ReferenceColumns = _referenceColumns.MatchColumns(ReferenceTable.Name, ReferenceTable.Columns).ToImmutableArray(); // If the name was not explicitly set then we generate one based on the table and column names if (Name == null) { Name = BuilderHelper.GenerateForeignKeyName(table.Schema, table.Name, KeyColumns.Select(c => c.Name), ReferenceTable.Schema, ReferenceTable.Name); } }
Ensure_When_We_Call_The_Authorize_Method_And_Handle_Failures_With_An_Unauthorized_ActionExecutingContext_The_Context_Result_Is_Set_To_The_Registered_Failure_Manager () { //arrange var conf = BuilderHelper.BuildConfigurationBuilder(); var context = FilterContextHelper.ContextFromExpression <TestController>(c => c.ControllerAction("test")); conf.Register(a => a.Method <TestController>(c => c.ControllerAction(default(string))).AuthorizedBy <UnauthorizedAuthorizer>().HandleFailureWith <HttpNotFoundResult>()); var service = BuilderHelper.ServiceBuilder(conf); //act service.Authorize(context, new TestPrincipal(), true); //assert Assert.That(context.Result.GetType(), Is.EqualTo(typeof(HttpNotFoundResult))); }
public void Build(System.Collections.Generic.List <string> scenesToBuild, UnityEditor.BuildTarget buildTarget, UnityEditor.BuildOptions buildOptions) { Console.WriteLine("ios_binary_with_special_bundle begin"); BuilderHelper.BootSceneFilename = "Assets/Scenes/Boot/PreBoot.unity"; const int basicSceneCount = 7; if (scenesToBuild.Count > basicSceneCount) { scenesToBuild.RemoveRange(basicSceneCount, scenesToBuild.Count - basicSceneCount); } BuilderHelper.CleanStreamingAssets(); BuilderHelper.Build(ref scenesToBuild, ref buildTarget, ref buildOptions, this, "index", null, false); BuilderHelper.CopyToStreamingAssets(); InJoy.UnityBuildSystem.AutoBuild.UnityBuildPlayer(scenesToBuild, buildTarget, buildOptions); Console.WriteLine("ios_binary_with_special_bundle end"); }
public void Deve_gerar_os_arquivos_de_sitemap() { List <Url> urls = new List <Url>(); urls.Add(BuilderHelper.UrlBuilder(ChangeFreq.always, null, DateTime.Now, string.Empty, 0.9m)); urls.Add(BuilderHelper.UrlBuilder(ChangeFreq.always, null, DateTime.Now, string.Empty, 0.9m)); SitemapEngine engine = new SitemapEngine() { UrlSite = "www.code4dev.net", Urls = urls, SitemapPath = @"C:\", SitemapName = "code4dev", MaxUrlSitemap = 10 }; engine.Builder(); }
public object BuildItem(PluginItemMetadata itemData, PluginRuntime plugin) { BuilderHelper.CheckParameter("ClassName", itemData); BuilderHelper.CheckParameter("Filter", itemData); // Support for simplified escaping inside XML tag string filter = itemData.Attributes["Filter"].Replace("{", "<").Replace("}", ">"); FilterWrapper wrapper; if (_serializer == null) { _serializer = new XmlSerializer(typeof(FilterWrapper)); } using (var reader = new StringReader(filter)) wrapper = (FilterWrapper)_serializer.Deserialize(reader); return(new MediaNavigationFilter(itemData.Attributes["ClassName"], wrapper.Filter)); }
private static void FillBuilderHelperXml(TypeDefinition type, PropertyDefinition property, BuilderHelper builderHelper) { if (type.Properties.Count(p => p.Name == property.Name + XmlAttributeConstants.SpecifiedPostFix) == 1) { //optional field builderHelper.Xml.IsOptional = true; } var xmlTypeAttribute = property.DeclaringType.CustomAttributes.FirstOrDefault(x => x.AttributeType.FullName == XmlAttributeConstants.XmlTypeAttribute); if (xmlTypeAttribute != null) { builderHelper.Xml.Namespace = GetNamespaceXml(xmlTypeAttribute, builderHelper.Xml.Namespace); } var xmlAttributeAttribute = property.CustomAttributes.FirstOrDefault(x => x.AttributeType.FullName == XmlAttributeConstants.XmlAttributeAttribute); if (xmlAttributeAttribute != null) { builderHelper.Xml.UsesAttribute = true; builderHelper.Xml.Name = GetAttributeName(xmlAttributeAttribute, builderHelper.Xml.Name); } var xmlElementAttribute = property.CustomAttributes.FirstOrDefault(x => x.AttributeType.FullName == XmlAttributeConstants.XmlElementAttribute); if (xmlElementAttribute != null) { builderHelper.Xml.Name = GetElementName(xmlElementAttribute, builderHelper.Xml.Name); builderHelper.Xml.DataType = GetDataType(xmlElementAttribute, builderHelper.Xml.DataType); } var xmlArrayItemAttribute = property.CustomAttributes.FirstOrDefault(x => x.AttributeType.FullName == XmlAttributeConstants.XmlArrayItemAttribute); if (xmlArrayItemAttribute != null) { builderHelper.Xml.ArrayItemName = GetElementName(xmlArrayItemAttribute, builderHelper.Xml.ArrayItemName); } }
private static void FillBuilderHelperData(TypeDefinition type, PropertyDefinition property, BuilderHelper builderHelper) { var dataMemberAttribute = property.CustomAttributes.FirstOrDefault(x => x.AttributeType.FullName == DataAttributeConstants.DataMemberAttribute); if (dataMemberAttribute != null) { builderHelper.Data.Name = GetName(dataMemberAttribute, builderHelper.Data.Name); builderHelper.Data.Namespace = GetNamespaceData(dataMemberAttribute, builderHelper.Data.Namespace); builderHelper.Data.EmitDefaultValue = GetEmitDefaultValue(dataMemberAttribute, builderHelper.Data.EmitDefaultValue); builderHelper.Data.IsRequired = GetIsRequired(dataMemberAttribute, builderHelper.Data.IsRequired); builderHelper.Data.Order = GetOrder(dataMemberAttribute, builderHelper.Data.Order); } }