public static void Configurator(Type from, Type to, MappingSettings settings) { settings.MappingItems = settings.MappingItems. Where( mi => mi.SourceMember != null). Join( settings.MappingItems.Where( mi => mi.DestinationMember != null), mi => mi.SourceMember.Name.ToUpper(), mi => mi.DestinationMember.Name.ToUpper(), (omi, imi) => new MappingItem(omi.SourceMember, imi.DestinationMember)). ToArray(); }
public GoogleOptimizeRouteService(IOptions<MappingSettings> mappingSettings, ILogger<GoogleOptimizeRouteService> logger, HttpClient httpClient = null) { _mappingSettings = mappingSettings?.Value; _logger = logger; _httpClient = httpClient ?? new HttpClient(); }
/// <summary> /// This method resolves the Uri against the script. /// </summary> /// <param name="id">The uri to match.</param> /// <param name="userAgent">The current user agent.</param> /// <param name="variables">The request variables.</param> /// <param name="success">Returns success if the uri and included parameters were matched successfully.</param> /// <param name="map">The map or null is not matched.</param> /// <returns>Returns true if the uri was identified.</returns> public bool ResolveUri(string server, Uri id, string userAgent, string method, IDictionary<string, string> variables, out bool success, MappingSettings map) { if (!mCompiled) throw new InvalidOperationException("The ControllerScript has not been compiled."); success = false; //Match the server if (!ResolveMapping(mMatchServer, server, method, variables, out success, map)) return false; if (success) return true; //Match the protocol if (!ResolveMapping(mMatchProtocol, id.Scheme, method, variables, out success, map)) return false; if (success) return true; //Match the domain if (!ResolveMapping(mMatchDomain, id.Authority, method, variables, out success, map)) return false; if (success) return true; //Match the user-agent if there is one. if (userAgent != null && userAgent != "" && !ResolveMapping(mMatchUserAgent, userAgent, method, variables, out success, map)) return false; if (success) return true; //Match the path if (!ResolveMapping(mMatchPath, id.LocalPath, method, variables, out success, map)) return false; return true; }
internal ANumericValueOutCommand(int id, string name, TargetType target, ARange <T> range, MappingSettings rawSettings) : base(id, name, target, rawSettings) { if (!typeof(T).IsNumber()) { throw new Exception("T must be a numeric type."); } MinValue = range.MinValue; MaxValue = range.MaxValue; RawSettings.ValueUIType = ValueUIType.Slider; }
/// <summary> /// Updates the specified object in the IndexWriter. /// </summary> /// <typeparam name="T"> /// The type of the object to update. /// </typeparam> /// <param name="writer"> /// The IndexWriter to update the object in. /// </param> /// <param name="obj"> /// The new object to write. /// </param> /// <param name="kind"> /// The kind of type to restrict the update operation to. /// </param> /// <param name="settings"> /// The MappingSettings to use when creating the Document to add to the index. /// </param> /// <param name="selection"> /// The Query which selects the item in the index. /// </param> /// <param name="analyzer"> /// The Analyzer to use. /// </param> public static void Update <T>(this IndexWriter writer, T obj, DocumentObjectTypeKind kind, MappingSettings settings, Query selection, Analyzer analyzer) { if (null == writer) { throw new ArgumentNullException("writer"); } else if (null == obj) { throw new ArgumentNullException("obj"); } else if (null == settings) { throw new ArgumentNullException("settings"); } else if (null == selection) { throw new ArgumentNullException("selection"); } else if (null == analyzer) { throw new ArgumentNullException("analyzer"); } writer.DeleteDocuments <T>(kind, selection); writer.AddDocument(obj.ToDocument <T>(settings), analyzer); }
/// <summary> /// create a mappingSet based on the data in the CSV file /// </summary> /// <param name="model">the model that contains the elements</param> /// <param name="filePath">the path to the CSV file</param> /// <returns>a mapping set representing the mapping in the file</returns> public static MappingSet createMappingSet(Model model, string filePath, MappingSettings settings, Element sourceRootElement = null, Element targetRootElement = null) { MappingSet newMappingSet = null; var engine = new FileHelperEngine <CSVMappingRecord>(); var parsedFile = engine.ReadFile(filePath); int i = 1; Package rootPackage = null; foreach (CSVMappingRecord mappingRecord in parsedFile) { //find source var source = findElement(model, mappingRecord.sourcePath, sourceRootElement); //find target var target = findElement(model, mappingRecord.targetPath, targetRootElement); if (source == null) { EAOutputLogger.log(model, settings.outputName , string.Format("Could not find element that matches: '{0}'", mappingRecord.sourcePath) , 0, LogTypeEnum.error); } else if (target == null) { EAOutputLogger.log(model, settings.outputName , string.Format("Could not find element that matches: '{0}'", mappingRecord.targetPath) , 0, LogTypeEnum.error); } else { //first check if the mappingSet is already created if (newMappingSet == null) { //determine if this should be a PackageMappingSet or an ElementMappingSet if (sourceRootElement is Package) { rootPackage = sourceRootElement as Package; newMappingSet = new PackageMappingSet(sourceRootElement as Package, true); } else if (sourceRootElement is ElementWrapper) { rootPackage = sourceRootElement.owningPackage as Package; newMappingSet = new ElementMappingSet(sourceRootElement as ElementWrapper, true); } else { rootPackage = source.owningPackage as Package; newMappingSet = new PackageMappingSet((Package)source.owningPackage, true); } } MappingLogic newMappingLogic = null; //check if there is any mapping logic if (!string.IsNullOrEmpty(mappingRecord.mappingLogic)) { if (settings.useInlineMappingLogic) { newMappingLogic = new MappingLogic(mappingRecord.mappingLogic); } else { //Check fo an existing mapping logic newMappingLogic = getExistingMappingLogic(model, settings, mappingRecord.mappingLogic, rootPackage); if (newMappingLogic == null) { var mappingElement = model.factory.createNewElement(rootPackage, "mapping logic " + i, settings.mappingLogicType) as ElementWrapper; if (mappingElement != null) { //increase counter for new mapping element name i++; mappingElement.notes = mappingRecord.mappingLogic; mappingElement.save(); //create the mappingLogic newMappingLogic = new MappingLogic(mappingElement); } else { //else we create an inline mapping logic anyway newMappingLogic = new MappingLogic(mappingRecord.mappingLogic); } } } } Mapping newMapping = null; var sourceAssociationEnd = source as AssociationEnd; var targetAssociationEnd = target as AssociationEnd; //create the new mapping //we can't create connector mappings for mappings to or from associations so we have to use tagged value mappings for those. if (settings.useTaggedValues || sourceAssociationEnd != null || targetAssociationEnd != null) { //if the source or target are associationEnds then we replace them by their association if (sourceAssociationEnd != null) { source = sourceAssociationEnd.association as Element; } if (targetAssociationEnd != null) { target = targetAssociationEnd.association as Element; } newMapping = new TaggedValueMapping(source, target, mappingRecord.sourcePath, mappingRecord.targetPath, settings); } else { newMapping = new ConnectorMapping(source, target, mappingRecord.sourcePath, mappingRecord.targetPath, settings); } if (newMappingLogic != null) { newMapping.mappingLogic = newMappingLogic; } newMapping.save(); newMappingSet.addMapping(newMapping); } } return(newMappingSet); }
public AttributeMappingNode(TSF_EA.AttributeWrapper sourceAttribute, ElementMappingNode parent, MappingSettings settings, MP.ModelStructure structure, bool isTarget) : this(sourceAttribute, parent, settings, structure, null, isTarget) { }
public static MappingSet createMappingSet(ElementWrapper sourceRoot, ElementWrapper targetRoot, MappingSettings settings) { //first create the root nodes var sourceRootNode = createNewRootNode(sourceRoot, settings); var targetRootNode = createNewRootNode(targetRoot, settings); //then create the new mappingSet var mappingSet = new MappingSet(sourceRootNode, targetRootNode, settings); return(mappingSet); }
public ConnectorMapping(Element source, Element target, string sourcePath, string targetPath, MappingSettings settings) : base(source, target, sourcePath, targetPath) { var sourceAttribute = source as TFS_EA.Attribute; var targetAttribute = target as TFS_EA.Attribute; ElementWrapper sourceOwner = sourceAttribute != null ? sourceAttribute.owner as ElementWrapper : source as ElementWrapper; ElementWrapper targetOwner = targetAttribute != null ? targetAttribute.owner as ElementWrapper: null as ElementWrapper; if (sourceOwner != null & targetOwner != null) { //create the connector wrappedConnector = sourceOwner.model.factory.createNewElement <UML.Classes.Kernel.Association> (sourceOwner, string.Empty) as Association; //set source and target wrappedConnector.source = source; wrappedConnector.target = target; wrappedConnector.save(); } }
public AttributeMappingNode(TSF_EA.Attribute sourceAttribute, ClassifierMappingNode parent, MappingSettings settings, MP.ModelStructure structure) : base(sourceAttribute, parent, settings, structure) { }
public AttributeMappingNode(TSF_EA.Attribute sourceAttribute, MappingSettings settings, MP.ModelStructure structure) : this(sourceAttribute, null, settings, structure) { }
public ElementMappingNode(TSF_EA.ElementWrapper sourceElement, MappingNode parent, MappingSettings settings, MP.ModelStructure structure, UML.Classes.Kernel.NamedElement virtualOwner, bool isTarget) : base(sourceElement, parent, settings, structure, virtualOwner, isTarget) { }
public ElementMappingNode(TSF_EA.ElementWrapper sourceElement, MappingNode parent, MappingSettings settings, MP.ModelStructure structure, bool isTarget) : this(sourceElement, parent, settings, structure, null, isTarget) { }
public AssociationMappingNode(TSF_EA.Association sourceAssociation, MappingSettings settings, MP.ModelStructure structure) : this(sourceAssociation, null, settings, structure) { }
public TaggedValueMapping(Element source, Element target, string sourcePath, string targetPath, MappingSettings settings) : base(source, target, sourcePath, targetPath) { string tagName = settings.linkedAttributeTagName; if (target is ConnectorWrapper) { tagName = settings.linkedAssociationTagName; } string tagComments = string.Empty; if (!string.IsNullOrEmpty(sourcePath)) { tagComments = KeyValuePairsHelper.setValueForKey("mappingSourcePath", this.stripPathFromElementName(source, sourcePath), tagComments); } if (!string.IsNullOrEmpty(targetPath)) { tagComments = KeyValuePairsHelper.setValueForKey("mappingTargetPath", this.stripPathFromElementName(target, targetPath), tagComments); } this.wrappedTaggedValue = source.addTaggedValue(tagName, target.uniqueID, tagComments, true); }
public ApiRecordingCSharpDiffWriter(DiffRecorder diffRecorder, MappingSettings settings, bool includePseudoCustomAttributes) : base(diffRecorder, settings, Enumerable.Empty <DiffComment>(), includePseudoCustomAttributes) { _diffRecorder = diffRecorder; _settings = settings; }
public static MappingNode createMappingNode(UML.Classes.Kernel.NamedElement source, MappingNode parent, MappingSettings settings) { //AttributeMappingNode var attributeSource = source as TSF.UmlToolingFramework.Wrappers.EA.Attribute; if (attributeSource != null) { return(new AttributeMappingNode(attributeSource, parent as ClassifierMappingNode, settings, parent.structure)); } //AssociationMappingNode var associationSource = source as Association; if (associationSource != null) { return(new AssociationMappingNode(associationSource, parent as ClassifierMappingNode, settings, parent.structure)); } //ClassifierMappingNode var classifierSource = source as ElementWrapper; if (classifierSource != null) { return(new ClassifierMappingNode(classifierSource, parent, settings, parent.structure)); } //not a valid source type, return null return(null); }
private static ICciDifferenceWriter GetDifferenceWriter(TextWriter writer, IDifferenceFilter filter, bool enforceOptionalRules, bool mdil, bool excludeNonBrowsable, string remapFile, bool groupByAssembly, string leftOperand, string rightOperand, string excludeAttributes, bool allowDefaultInterfaceMethods) { CompositionHost container = GetCompositionHost(); bool RuleFilter(IDifferenceRuleMetadata ruleMetadata) { if (ruleMetadata.OptionalRule && !enforceOptionalRules) { return(false); } if (ruleMetadata.MdilServicingRule && !mdil) { return(false); } return(true); } if (mdil && excludeNonBrowsable) { Trace.TraceWarning("Enforcing MDIL servicing rules and exclusion of non-browsable types are both enabled, but they are not compatible so non-browsable types will not be excluded."); } var settings = new MappingSettings { Comparers = GetComparers(remapFile), Filter = GetCciFilter(mdil, excludeNonBrowsable) }; settings.DiffFilter = GetDiffFilter(settings.Filter); settings.DiffFactory = new ElementDifferenceFactory(container, RuleFilter); settings.GroupByAssembly = groupByAssembly; settings.IncludeForwardedTypes = true; if (filter == null) { filter = new DifferenceFilter <IncompatibleDifference>(); } var diffWriter = new DifferenceWriter(writer, settings, filter); ExportCciSettings.StaticSettings = settings.TypeComparer; ExportCciSettings.StaticOperands = new DifferenceOperands() { Contract = leftOperand, Implementation = rightOperand }; ExportCciSettings.StaticAttributeFilter = GetAttributeFilter(HostEnvironment.SplitPaths(excludeAttributes)); ExportCciSettings.StaticRuleSettings = new RuleSettings { AllowDefaultInterfaceMethods = allowDefaultInterfaceMethods }; // Always compose the diff writer to allow it to import or provide exports container.SatisfyImports(diffWriter); return(diffWriter); }
public static ClassifierMappingNode createNewRootNode(ElementWrapper rootElement, MappingSettings settings) { //depending on the type of root we create a dataModel structure (Package) or a Message structure (class). return(rootElement is Package ? new ClassifierMappingNode(rootElement, settings, MP.ModelStructure.DataModel) : new ClassifierMappingNode(rootElement, settings, MP.ModelStructure.Message)); }
public AssociationMappingNode(TSF_EA.Association sourceAssociation, ElementMappingNode parent, MappingSettings settings, MP.ModelStructure structure, bool isTarget) : this(sourceAssociation, parent, settings, structure, null, isTarget) { }
public AttributeMappingNode(TSF_EA.AttributeWrapper sourceAttribute, ElementMappingNode parent, MappingSettings settings, MP.ModelStructure structure, UML.Classes.Kernel.NamedElement virtualOwner, bool isTarget) : base((UML.Classes.Kernel.NamedElement)sourceAttribute, parent, settings, structure, virtualOwner, isTarget) { }
public AssociationMappingNode(TSF_EA.Association sourceAssociation, ElementMappingNode parent, MappingSettings settings, MP.ModelStructure structure, UML.Classes.Kernel.NamedElement virtualOwner, bool isTarget) : base(sourceAssociation, parent, settings, structure, virtualOwner, isTarget) { }
internal FloatInCommand(int id, string name, Enums.TargetType target, MappingSettings rawSettings) : base(id, name, target, new T(), rawSettings) { RawSettings.ValueUIType = ValueUIType.Slider; }
public DifferenceWriter(TextWriter writer, MappingSettings settings, IDifferenceFilter filter) : base(settings, filter) { _writer = writer; _differences = new List <Difference>(); }
private static ICciDifferenceWriter GetDifferenceWriter(TextWriter writer, IDifferenceFilter filter, bool enforceOptionalRules, bool mdil, bool excludeNonBrowsable, bool includeInternals, bool excludeCompilerGenerated, string remapFile, bool groupByAssembly, string leftOperand, string rightOperand, IEnumerable <string> excludeAttributes, bool allowDefaultInterfaceMethods, bool usesMSBuildLog) { CompositionHost container = GetCompositionHost(); bool RuleFilter(IDifferenceRuleMetadata ruleMetadata) { if (ruleMetadata.OptionalRule && !enforceOptionalRules) { return(false); } if (ruleMetadata.MdilServicingRule && !mdil) { return(false); } return(true); } if (mdil && excludeNonBrowsable) { Trace.TraceWarning("Enforcing MDIL servicing rules and exclusion of non-browsable types are both enabled, but they are not compatible so non-browsable types will not be excluded."); } if (includeInternals && (mdil || excludeNonBrowsable)) { Trace.TraceWarning("Enforcing MDIL servicing rules or exclusion of non-browsable types are enabled " + "along with including internals -- an incompatible combination. Internal members will not be included."); } ICciFilter cciFilter = GetCciFilter(mdil, excludeNonBrowsable, includeInternals, excludeCompilerGenerated); var settings = new MappingSettings { Comparers = GetComparers(remapFile), DiffFactory = new ElementDifferenceFactory(container, RuleFilter), DiffFilter = GetDiffFilter(cciFilter), Filter = cciFilter, GroupByAssembly = groupByAssembly, IncludeForwardedTypes = true, }; if (filter == null) { filter = new DifferenceFilter <IncompatibleDifference>(); } var diffWriter = new DifferenceWriter(writer, settings, filter, usesMSBuildLog); ExportCciSettings.StaticSettings = settings.TypeComparer; ExportCciSettings.StaticOperands = new DifferenceOperands() { Contract = leftOperand, Implementation = rightOperand }; ExportCciSettings.StaticAttributeFilter = GetAttributeFilter(excludeAttributes); ExportCciSettings.StaticRuleSettings = new RuleSettings { AllowDefaultInterfaceMethods = allowDefaultInterfaceMethods }; // Always compose the diff writer to allow it to import or provide exports container.SatisfyImports(diffWriter); return(diffWriter); }
public DifferenceTraverser(MappingSettings settings, IDifferenceFilter filter) : base(settings) { _filter = filter; }
/// <summary> /// This method resets the request so that it can be reused. /// </summary> public override void Reset() { mData = null; mSettings = null; base.Reset(); }
public DiffCSharpWriter(IStyleSyntaxWriter writer, MappingSettings settings, IEnumerable <DiffComment> diffComments) : this(writer, settings, diffComments, includePseudoCustomAttributes : false) { }
/// <summary> /// This method validates the particular piece of data against the script. /// </summary> /// <param name="matchCollection">The match collection.</param> /// <param name="data">The data to match.</param> /// <param name="method">The method to match.</param> /// <param name="variables">The variable collection.</param> /// <param name="success">An out paramterer denoting a successful match.</param> /// <param name="map">The map setting for the Uri.</param> /// <returns>Returns true if a match was made successfully, or no data was available to match.</returns> protected virtual bool ResolveMapping(Dictionary<int, Mapping> matchCollection, string data, string method, IDictionary<string, string> variables, out bool success, MappingSettings map) { success = false; if (matchCollection == null || matchCollection.Count == 0) return true; foreach (int mapID in matchCollection.Keys) { Mapping mapCheck = matchCollection[mapID]; Match tempMatch = null; Regex tempRegex = null; if (!mapCheck.RXMatch(data, out tempMatch, out tempRegex)) continue; if (mapCheck.MappingVerb != null && mapCheck.MappingVerb != "*" && mapCheck.MappingVerb != method && MethodCheckMultiple(mapCheck.MappingVerb, method)) continue; map.Set(mapCheck); //If this is not a redirect we should verify the variables. if (mapCheck.Redirect == null) success = VerifyVariables(variables, tempMatch, tempRegex); if (mapCheck.OutputColl.Count > 0) success = true; return true; } return false; }
public DiffCSharpWriter(IStyleSyntaxWriter writer, MappingSettings settings) : this(writer, settings, null, false) { }
/// <inheritdoc /> public GoogleOptimizeRouteService(IOptions <MappingSettings> mappingSettings, ILogger <GoogleOptimizeRouteService> logger, IHttpClient httpClient) { _mappingSettings = mappingSettings?.Value; _logger = logger; _httpClient = httpClient; }
public ElementMappingNode(TSF_EA.ElementWrapper sourceElement, MappingSettings settings, MP.ModelStructure structure) : this(sourceElement, null, settings, structure) { }