Наследование: System.Dynamic.DynamicObject, IValueContext
Пример #1
0
        internal static ProjectElement GetTargetItem(this ProjectTargetElement target, View view)
        {
            // get the member name and data from the view, and create/lookup the item.
            // return the item.
            switch (view.MemberName) {
                case "PropertyGroup":
                    break;
                case "ItemGroup":
                    break;
                case "AfterTargets":
                    break;

                default:
                    //

                    var taskName = view.MemberName;
                    if (TaskClasses.Value.ContainsKey(taskName.ToLower())) {
                        // for tasks we recognize
                        var tskType = TaskClasses.Value[taskName.ToLower()];

                        var tsk = target.AddTask(taskName);
                        var required = tskType.RequiredInputs.ToList();

                        foreach (var n in view.GetChildPropertyNames()) {
                            var prop = view.GetProperty(n);

                            if (n == "Condition") {
                                tsk.Condition = prop;
                                continue;
                            }

                            if (required.Contains(n)) {
                                required.Remove(n);
                            } else {
                                if (!tskType.OptionalInputs.Contains(n)) {
                                    Event<Warning>.Raise("Unknown Parameter", "Task '{0}' does not appear to have an input parameter '{1}'", taskName, n);

                                    // could we set some item collection based on these?
                                    // TODO: maybe.
                                }
                            }

                            tsk.SetParameter(n, prop.Values.CollapseToString(";"));
                        }

                        foreach (var r in required) {
                            Event<Warning>.Raise("Missing Parameter", "Task '{0}' is missing required input parameter '{1}'", taskName, r);
                        }

                        var outputs = tskType.Outputs.ToList();

                        foreach (var n in view.GetIndexedPropertyNames()) {
                            var prop = view.GetProperty(n);
                            // an output paramter.
                            var nam = prop.GetProperty(prop.GetChildPropertyNames().FirstOrDefault());

                            if (!tskType.Outputs.Contains(nam.Value)) {
                                Event<Warning>.Raise("Unknown Parameter", "Task '{0}' does not appear to have an output parameter '{1}'", taskName, nam.Value);
                            }

                            if (outputs.Contains(nam.Value)) {
                                outputs.Remove(nam.Value);
                            }

                            tsk.AddOutputProperty(nam.Value, nam.MemberName);
                            tsk.AddOutputItem(nam.Value, nam.MemberName);
                        }

                        foreach (var output in outputs) {
                            // add in any unreferenced outputs as themselves.
                            tsk.AddOutputProperty(output, output);
                            tsk.AddOutputItem(output, output);
                        }
                        return tsk;
                    }

                    // for tasks we don't recognize
                    var tsk2 = target.AddTask(taskName);

                    Event<Warning>.Raise("Unrecognized Task", "Task '{0}' is not recognized.", taskName);

                    foreach (var n in view.GetChildPropertyNames()) {
                        var prop = view.GetProperty(n);
                        if(n == "Condition") {
                            tsk2.Condition = prop;
                            continue;
                        }
                        tsk2.SetParameter(n, prop.Values.CollapseToString(";"));
                    }

                    foreach (var n in view.GetIndexedPropertyNames()) {
                        var prop = view.GetProperty(n);
                        // an output paramter.
                        var nam = prop.GetProperty(prop.GetChildPropertyNames().FirstOrDefault());
                        tsk2.AddOutputProperty(nam.Value, nam.MemberName);
                        tsk2.AddOutputItem(nam.Value, nam.MemberName);
                    }
                    return tsk2;

            }
            return null;
        }
Пример #2
0
 private View CreatePlaceholderView(string placeholderName) {
     var result = new View(new PlaceholderMap(placeholderName, Enumerable.Empty<ToRoute>()));
     map.MergeChild( this,  result);
     return map[placeholderName];
 }
Пример #3
0
 protected static View Unroll(string memberName, View view)
 {
     if (view._map.MemberName != memberName) {
         var p = memberName.IndexOf('.');
         if (p > -1) {
             return new View(new PlaceholderMap(memberName.Substring(0, p), new ToRoute[] {
                 (() => Unroll(memberName.Substring(p + 1), view))
             }) {
                 Active = view._map.Active
             });
         }
         view._map.MemberName = memberName;
     }
     return view;
 }
Пример #4
0
 protected static View Unroll(string memberName, View view, int priority) {
     if (view._map.MemberName != memberName) {
         var p = memberName.IndexOf('.');
         if (p > -1) {
             var v= new View(new PlaceholderMap(memberName.Substring(0, p), new ToRoute[] {
                 (new ToRoute(() => Unroll(memberName.Substring(p + 1), view,priority)))
             }) {
                 Active = view._map.Active
             });
             v._map._aliasHistory = view._map._aliasHistory;
             return v;
         }
         view._map.MemberName = memberName;
     }
     return view;
 }