コード例 #1
0
        public OptionDependencyManager(
            [NotNull][ItemNotNull] ILoadTypeStep[] loadTypePostProcessingSteps,
            [NotNull][ItemNotNull] IGeneralStep[] generalPostProcessingSteps,
            [NotNull][ItemNotNull] IGeneralHouseholdStep[] generalHouseholdSteps,
            [NotNull][ItemNotNull] IHouseholdLoadTypeStep[] householdloadTypePostProcessingSteps,
            [NotNull][ItemNotNull] ILoadTypeSumStep[] loadtypeSumPostProcessingSteps
            )
        {
            List <IRequireOptions> allSteps = new List <IRequireOptions>();

            allSteps.AddRange(loadTypePostProcessingSteps);
            allSteps.AddRange(generalPostProcessingSteps);
            allSteps.AddRange(generalHouseholdSteps);
            allSteps.AddRange(householdloadTypePostProcessingSteps);
            allSteps.AddRange(loadtypeSumPostProcessingSteps);
            foreach (var step in allSteps)
            {
                foreach (var option in step.Options)
                {
                    if (!Dependencies.ContainsKey(option))
                    {
                        Dependencies.Add(option, new List <CalcOption>());
                    }

                    foreach (var neededOption in step.NeededOptions)
                    {
                        if (!Dependencies[option].Contains(neededOption))
                        {
                            Dependencies[option].Add(neededOption);
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: DagNode.cs プロジェクト: jwmxyz/randomdaggenerator
 public void UpdateDependencies()
 {
     foreach (DagEdge edge in PrevEdges)
     {
         if (!Dependencies.ContainsKey(edge.PrevNode.Id))
         {
             Dependencies.Add(edge.PrevNode.Id, edge.CommTime);
         }
     }
 }
コード例 #3
0
        /// <summary>
        /// Removes the ordered pair (s,t), if it exists
        /// </summary>
        /// <param name="s"></param>
        /// <param name="t"></param>
        public void RemoveDependency(string s, string t)
        {
            if (!Dependencies.ContainsKey(s))
            {
                return;
            }

            Dependencies[s].Remove(t);
            Dependees[t].Remove(s);
        }
コード例 #4
0
 /// <summary>
 /// Registra la clase que se instanciará como dependencia a la interfase
 /// </summary>
 /// <typeparam name="C">Clase</typeparam>
 /// <typeparam name="I">Interfase que implementa</typeparam>
 public static void Register <C, I>() where C : I, new()
 {
     if (!Dependencies.ContainsKey(typeof(I)))
     {
         Dependencies.Add(typeof(I), typeof(C));
     }
     else
     {
         Dependencies[typeof(I)] = typeof(C);
     }
 }
コード例 #5
0
        /// <summary>
        /// Removes all existing ordered pairs of the form (s,r).  Then, for each
        /// t in newDependents, adds the ordered pair (s,t).
        /// </summary>
        public void ReplaceDependents(string s, IEnumerable <string> newDependents)
        {
            if (Dependencies.ContainsKey(s))
            {
                foreach (var entry in Dependencies[s])
                {
                    Dependees[entry].Remove(s);
                }

                Dependencies[s].Clear();
            }

            foreach (var dependent in newDependents)
            {
                AddDependency(s, dependent);
            }
        }
コード例 #6
0
            private void PopulateHardCodedDependencies(string logicalName)
            {
                // Connection Roles have to be associated before
                switch (logicalName)
                {
                case Connection.EntityLogicalName:
                    if (!Dependencies.ContainsKey(ConnectionRoleAssociation.EntityLogicalName))
                    {
                        Dependencies.Add(ConnectionRoleAssociation.EntityLogicalName, new EntityDependencyRelationship(logicalName, ConnectionRoleAssociation.EntityLogicalName, Connection.Fields.Record1RoleId, false));
                    }
                    break;

                case ConnectionRoleAssociation.EntityLogicalName:
                    if (!Dependencies.ContainsKey(ConnectionRole.EntityLogicalName))
                    {
                        Dependencies.Add(ConnectionRole.EntityLogicalName, new EntityDependencyRelationship(logicalName, ConnectionRole.EntityLogicalName, ConnectionRoleAssociation.Fields.ConnectionRoleId, false));
                    }
                    break;
                }
            }
コード例 #7
0
        /// <summary>
        /// <para>Adds the ordered pair (s,t), if it doesn't exist</para>
        ///
        /// <para>This should be thought of as:</para>
        ///
        ///   s depends on t
        ///
        /// </summary>
        /// <param name="s"> s cannot be evaluated until t is</param>
        /// <param name="t"> t must be evaluated first.  S depends on T</param>
        public void AddDependency(string s, string t)
        {
            if (!Dependencies.ContainsKey(s))
            {
                Dependencies.Add(s, new List <string>());
            }

            if (Dependencies[s].Contains(t))
            {
                return;
            }

            Dependencies[s].Add(t);

            if (!Dependees.ContainsKey(t))
            {
                Dependees.Add(t, new List <string>());
            }

            Dependees[t].Add(s);
        }
コード例 #8
0
        public string GetStringOrder()
        {
            var sb         = new StringBuilder();
            var candidates = Dependencies.Keys.ToList <string>();

            foreach (var kvp in Dependencies)
            {
                foreach (var d in kvp.Value)
                {
                    if (candidates.Contains(d))
                    {
                        candidates.Remove(d);
                    }
                }
            }

            candidates.Sort();

            while (candidates.Count > 0)
            {
                sb.Append(candidates[0]);

                if (Dependencies.ContainsKey(candidates[0]))
                {
                    foreach (var d in Dependencies[candidates[0]])
                    {
                        // go through each dependency and see if it depends on others and it's not in sb.tostring.
                        bool          dependsOnOthers = false;
                        List <string> dependsOn       = new List <string>();

                        foreach (var kvp in Dependencies)
                        {
                            if (kvp.Value.Contains(d))
                            {
                                dependsOnOthers = true;
                                dependsOn.Add(kvp.Key);
                            }
                        }

                        if (!dependsOnOthers)
                        {
                            candidates.Add(d);
                        }
                        else
                        {
                            string temp       = sb.ToString();
                            bool   allDepsHit = true;

                            foreach (var s in dependsOn)
                            {
                                if (!temp.Contains(s))
                                {
                                    allDepsHit = false;
                                }
                            }

                            if (allDepsHit)
                            {
                                candidates.Add(d);
                            }
                        }
                    }
                    //candidates.AddRange(Dependencies[candidates[0]]);
                }

                candidates.RemoveAll(c => c == candidates[0]);
                candidates.Sort();
            }

            return(sb.ToString());
        }
コード例 #9
0
ファイル: BuildOrigin.cs プロジェクト: srijken/turtlebuild
        public override void ApplyProjectDependencies(PackageState state)
        {
            if (!state.DontUseProjectDependencies)             // Allow disabling for testing
            {
                // Add an initial set of dependencies directly from the project files
                foreach (TBLogConfiguration config in LogFile.Configurations)
                {
                    foreach (TBLogItem project in config.References.Projects)
                    {
                        string src = QQnPath.NormalizePath(project.FullSrc);

                        foreach (Origin o in state.Origins)
                        {
                            BuildOrigin bo = o as BuildOrigin;
                            if (bo == null)
                            {
                                continue;
                            }

                            if (QQnPath.Equals(bo.ProjectFile, src) && !Dependencies.ContainsKey(o))
                            {
                                EnsureDependency(o, DependencyType.LinkedTo);
                            }
                        }
                    }
                }
            }

            foreach (TBLogItem item in LogFile.AllProjectOutput)
            {
                FileData fd = state.Files[item.FullSrc];

                if (!string.IsNullOrEmpty(fd.CopiedFrom))
                {
                    FileData src;

                    if (state.Files.TryGetValue(fd.CopiedFrom, out src))
                    {
                        if (src.Origin != this)
                        {
                            EnsureDependency(src.Origin, item.IsCopy ? DependencyType.Required : DependencyType.LinkedTo);
                        }
                    }
                }
            }

            foreach (TBLogItem item in LogFile.AllContents)
            {
                FileData fd = state.Files[item.FullSrc];

                if (!string.IsNullOrEmpty(fd.CopiedFrom))
                {
                    FileData src;

                    if (state.Files.TryGetValue(fd.CopiedFrom, out src))
                    {
                        if (src.Origin != this)
                        {
                            EnsureDependency(src.Origin, DependencyType.Required);
                        }
                    }
                }
            }
        }
コード例 #10
0
 /// <summary>
 /// Returns true if the Entity Dependency Info depends on given Entity Dependency Info.
 /// </summary>
 /// <param name="nodeInfo">The info to check to see if it is a dependency.</param>
 /// <returns></returns>
 public bool DependsOn(EntityDependencyNodeInfo nodeInfo)
 {
     //return Dependencies.Contains(info.LogicalName) || info.Dependents.Contains(LogicalName);
     return(Dependencies.ContainsKey(nodeInfo.LogicalName));
 }
コード例 #11
0
ファイル: ConditionalSplit.cs プロジェクト: sajens/MAIME
        /// <summary>
        /// Maps the dependencies and properties in a SSIS graph into our graph model
        /// </summary>
        public override void MapDependenciesAndProperties()
        {
            // Get all input attributes
            List <Attribute> inputAttributes = IngoingEdges().First().Attributes.ToList();

            // Non-error outputs don't contain outputcolumns
            foreach (IDTSOutput100 output in ComponentRef.OutputCollection)
            {
                // Obtain destination
                Edge edge = OutgoingEdges().Find(e => e.Path.StartPoint.ID == output.ID);

                // Handle non-error outputs
                if (!output.IsErrorOut)
                {
                    Condition c = new Condition();

                    if (output.CustomPropertyCollection.Count == 1 && output.CustomPropertyCollection["IsDefaultOut"].Value)
                    {
                        //  change.ExpressionRef = null;
                        c.Expression = "IMTHEDEFAULTOUTPUT";
                        c.P          = uint.MaxValue;
                    }
                    else
                    {
                        // Obtain FriendlyExpression
                        c.ExpressionRef = output.CustomPropertyCollection["FriendlyExpression"];
                        c.Expression    = output.CustomPropertyCollection["FriendlyExpression"].Value;

                        // Obtain EvaluationOrder
                        c.EvaluationOrderRef = output.CustomPropertyCollection["EvaluationOrder"];
                        c.P = Convert.ToUInt32(c.EvaluationOrderRef.Value);
                    }

                    // If an output is connected to an edge, then set the obtained values
                    if (edge != null)
                    {
                        c.Dest          = edge.Destination;
                        edge.Attributes = inputAttributes;
                    }

                    // If expressionref is not null (is not a default case) then add it to conditions
                    if (c.ExpressionRef != null)
                    {
                        Conditions.Add(c);
                    }

                    c.OutputRef = output;
                }
                // Handle error output
                else
                {
                    foreach (IDTSOutputColumn100 errorOutputColumn in output.OutputColumnCollection)
                    {
                        Attribute outputAttribute = new Attribute(errorOutputColumn.LineageID, errorOutputColumn.Name,
                                                                  errorOutputColumn.DataType, errorOutputColumn);

                        switch (errorOutputColumn.Name)
                        {
                        case "ErrorCode":
                            ErrorOutput.ErrorCode = outputAttribute;
                            break;

                        case "ErrorColumn":
                            ErrorOutput.ErrorColumn = outputAttribute;
                            break;

                        default:
                            ErrorOutput.Attributes.Add(outputAttribute);
                            break;
                        }
                    }

                    // Set error output on edge
                    edge?.Attributes.AddRange(ErrorOutput.Attributes);
                    edge?.Attributes.Add(ErrorOutput?.ErrorCode);
                    edge?.Attributes.Add(ErrorOutput?.ErrorColumn);
                }
            }

            // Map dependencies
            foreach (Edge outputEdge in OutgoingEdges())
            {
                foreach (Attribute attribute in outputEdge.Attributes)
                {
                    // If dependency already is defined from another output, we skip it.
                    if (!Dependencies.ContainsKey(attribute))
                    {
                        // Simply just depend the attribute on it self, since it is the same reference that is used as an input
                        Dependencies[attribute] = new List <Attribute> {
                            attribute
                        }
                    }
                    ;
                }
            }

            // ErrorCode and ErrorColumn do depend on every single input attribute, since they are only deletable when
            // all other attributes are deleted
            Dependencies[ErrorOutput.ErrorCode]   = inputAttributes;
            Dependencies[ErrorOutput.ErrorColumn] = inputAttributes;
        }
コード例 #12
0
ファイル: DataConversion.cs プロジェクト: sajens/MAIME
        public override void MapDependenciesAndProperties()
        {
            throw new NotImplementedException();
            //Start off by getting a list of input attributes to start off.
            //List<Attribute> inputAttributes = new List<Attribute>();
            //foreach (IDTSInput100 input in componentRef.InputCollection)
            //{
            //    foreach (IDTSInputColumn100 column in input.InputColumnCollection)
            //    {
            //        inputAttributes.Add(inputAttributes.);
            //    }
            //}

            //Go through output to fill "dependencies" + "conversions"
            foreach (IDTSOutput100 output in ComponentRef.OutputCollection)
            {
                Edge edge = OutgoingEdges().Find(e => e.Path.StartPoint.ID == output.ID);

                //If it's not the error output
                if (!output.IsErrorOut)
                {
                    foreach (IDTSOutputColumn100 column in output.OutputColumnCollection)
                    {
                        Attribute outputAttribute = new Attribute(column.LineageID, column.Name, column.DataType, column);

                        int val = column.CustomPropertyCollection["SourceInputColumnLineageID"].Value;

                        //The input for "dependencies" will always just be a list of one input
                        List <Attribute> dependencyInputAttributeList = IngoingEdges().First().Attributes.FindAll(a => a.Id == val);

                        //Add tuple + fill in depencies
                        Dependencies.Add(outputAttribute, dependencyInputAttributeList);
                        Conversion conversion = new Conversion();
                        conversion.Output = outputAttribute;
                        conversion.A      = dependencyInputAttributeList[0];
                        Conversions.Add(conversion);


                        //Add the attribute to the edge
                        //TODO: if there will be an error output, we might not be able to use "find()" anymore.
                        edge?.Attributes.Add(outputAttribute);
                    }
                }   //error output
                else
                {
                    foreach (IDTSOutputColumn100 errorOutputColumn in output.OutputColumnCollection)
                    {
                        Attribute outputAttribute = new Attribute(errorOutputColumn.LineageID, errorOutputColumn.Name,
                                                                  errorOutputColumn.DataType, errorOutputColumn);

                        switch (errorOutputColumn.Name)
                        {
                        case "ErrorCode":
                            Dependencies.Add(outputAttribute, new List <Attribute>());
                            break;

                        case "ErrorColumn":
                            Dependencies.Add(outputAttribute, new List <Attribute>());
                            break;
                        }
                        edge?.Attributes.Add(outputAttribute);
                    }
                }

                //attributes that are just passing through.
                foreach (Attribute outputAttribute in IngoingEdges().First().Attributes)
                {
                    edge = OutgoingEdges().Find(e => e.Path.StartPoint.ID == output.ID);
                    //Output attribute has already been created.
                    if (Dependencies.ContainsKey(outputAttribute))
                    {
                        //Add an additional dependency to existing mapping
                        Dependencies[outputAttribute].Add(outputAttribute);
                    }
                    else    //first time attribute has been encountered.
                    {
                        //Create a new list with just one new element(itself)
                        List <Attribute> outputList = new List <Attribute> {
                            outputAttribute
                        };
                        Dependencies.Add(outputAttribute, outputList);
                    }
                    edge?.Attributes.Add(outputAttribute);
                }



                //TODO: Consider how to set the two error things(attributes) on the error output
            }
        }