示例#1
0
        /// <summary>
        /// General drawer used for every drawed instance
        /// </summary>
        /// <param name="instance">Instance to be draw</param>
        private void generalDrawer(DrawedInstance instance)
        {
            var instanceInfo     = instance.WrappedInstance.Info;
            var componentInfo    = _assembly.Loader.GetComponentInfo(instanceInfo);
            var definingAssembly = _assembly.Loader.AppDomain.GetDefiningAssembly(instanceInfo);

            instance.SetProperty("DefiningAssembly", definingAssembly.Name);
            GeneralDefinitionProvider.Draw(instance, componentInfo);
        }
示例#2
0
        /// <summary>
        /// General drawing provider that is commonly used for all instances
        /// Drawings of required instances are specialized by concrete drawers.
        /// </summary>
        /// <param name="instance">Instance to be drawn.</param>
        private void generalDrawer(DrawedInstance instance)
        {
            if (instance.WrappedInstance.CreationNavigation != null)
            {
                instance.Drawing.AddCommand(new CommandDefinition("Navigate to", () =>
                {
                    _vs.SafeRunAction(() => instance.WrappedInstance.CreationNavigation(),
                                      "Instance navigation failed");
                }));
            }

            instance.Drawing.AddEdit(new EditDefinition("Remove", (v) =>
            {
                return(_vs.SafeRun(() =>
                {
                    var view = (v as EditView).CopyView();
                    view.Remove(instance.WrappedInstance);
                    return EditView.Wrap(view);
                }, "Removing edit failed"));
            }, (v) =>
            {
                var view = (v as EditView).CopyView();
                return(view.CanRemove(instance.WrappedInstance));
            }));

            var instanceInfo  = instance.WrappedInstance.Info;
            var componentInfo = _loader.GetComponentInfo(instanceInfo);
            var assembly      = _loader.AppDomain.GetDefiningAssembly(instanceInfo);

            if (assembly != null)
            {
                instance.SetProperty("DefiningAssembly", assembly.Name);
            }

            //provide general drawing
            foreach (var generalDrawer in _exportedGeneralDrawingProvider)
            {
                generalDrawer(instance, componentInfo);
            }
        }
示例#3
0
        /// <summary>
        /// Handles the entry instance.
        /// </summary>
        /// <param name="instance">The instance.</param>
        private static void handleEntryInstance(DrawedInstance instance)
        {
            //instance that was pasted on analysis start
            instance.SetProperty("EntryInstance", "");
            var wrappedInstance = instance.WrappedInstance;
            var creationBlock   = wrappedInstance.CreationBlock;

            if (creationBlock == null)
            {
                return;
            }

            var firstBlockInfo = creationBlock.FirstBlock.Info;

            if (firstBlockInfo != null && firstBlockInfo.BlockTransformProvider != null)
            {
                var navigation = firstBlockInfo.BlockTransformProvider.GetNavigation();
                if (navigation != null)
                {
                    instance.Drawing.AddCommand(new CommandDefinition("Navigate to", () => navigation()));
                }
            }
        }
示例#4
0
        /// <summary>
        /// Draws the specified instance.
        /// </summary>
        /// <param name="instance">The draw instance.</param>
        /// <param name="info">The component information available for draw instance.</param>
        public static void Draw(DrawedInstance instance, ComponentInfo info)
        {
            if (instance == null || instance.WrappedInstance == null)
            {
                return;
            }

            if (instance.WrappedInstance.IsDirty)
            {
                //instance is dirty
                instance.SetProperty("IsDirty", "");
            }

            if (info == null)
            {
                return;
            }

            instance.SetProperty("DefiningAssembly", info.DefiningAssembly.Name);

            if (instance.WrappedInstance.IsEntryInstance)
            {
                handleEntryInstance(instance);
            }

            foreach (var export in info.Exports)
            {
                var connector = instance.GetJoinPoint(export);

                setInherited(connector, export);
                setProperty(connector, "Kind", "Export");
                setProperty(connector, "Contract", export.Contract);
                setProperty(connector, "ContractType", export.ExportType);

                setMetaProperties(connector, "$Meta", export.Meta);
            }

            foreach (var export in info.SelfExports)
            {
                var connector = instance.GetJoinPoint(export);

                setInherited(connector, export);
                setProperty(connector, "Kind", "SelfExport");
                setProperty(connector, "Contract", export.Contract);
                setProperty(connector, "ContractType", export.ExportType);

                setMetaProperties(connector, "$Meta", export.Meta);
            }

            foreach (var import in info.Imports)
            {
                var connector = instance.GetJoinPoint(import);

                setProperty(connector, "Kind", "Import");
                setProperty(connector, "Contract", import.Contract);
                setProperty(connector, "ContractType", import.ImportTypeInfo.ImportType);
                if (import.AllowMany)
                {
                    setProperty(connector, "ContractItemType", import.ImportTypeInfo.ItemType);
                }
                setProperty(connector, "AllowMany", import.AllowMany);
                setProperty(connector, "AllowDefault", import.AllowDefault);
                setProperty(connector, "IsPrerequisity", import.IsPrerequisity);
            }
        }
示例#5
0
 /// <summary>
 /// Sets value of given property.
 /// </summary>
 /// <param name="property">The property.</param>
 /// <param name="value">The value.</param>
 public void SetProperty(string property, string value)
 {
     Instance.SetProperty(property, value);
 }