Exemple #1
0
 public PluginData(
     string name,
     string group,
     string description,
     IClientData clientData,
     PluginFlags flags,
     Version version,
     Uri uri,
     AppDomain appDomain,
     Assembly assembly,
     AssemblyName assemblyName,
     string fileName,
     string typeName,
     CommandDataList commands,
     PolicyDataList policies,
     LongList commandTokens,
     LongList functionTokens,
     LongList policyTokens,
     LongList traceTokens,
     ResourceManager resourceManager,
     ObjectDictionary auxiliaryData,
     long token
     )
 {
     this.kind            = IdentifierKind.PluginData;
     this.id              = AttributeOps.GetObjectId(this);
     this.name            = name;
     this.group           = group;
     this.description     = description;
     this.clientData      = clientData;
     this.flags           = flags;
     this.version         = version;
     this.uri             = uri;
     this.appDomain       = appDomain;
     this.assembly        = assembly;
     this.assemblyName    = assemblyName;
     this.fileName        = fileName;
     this.typeName        = typeName;
     this.commands        = commands;
     this.policies        = policies;
     this.commandTokens   = commandTokens;
     this.functionTokens  = functionTokens;
     this.policyTokens    = policyTokens;
     this.traceTokens     = traceTokens;
     this.resourceManager = resourceManager;
     this.auxiliaryData   = auxiliaryData;
     this.token           = token;
 }
Exemple #2
0
        /// <summary>
        ///   This is the constructor used by the core library to create an
        ///   instance of the plugin, passing the necessary data to be used
        ///   for initializing the plugin.
        /// </summary>
        ///
        /// <param name="pluginData">
        ///   An instance of the plugin data component used to hold the data
        ///   necessary to fully initialize the plugin instance.  This
        ///   parameter may be null.  Derived plugins are free to override
        ///   this constructor; however, they are very strongly encouraged to
        ///   call this constructor (i.e. the base class constructor) in that
        ///   case.
        /// </param>
        public Default(
            IPluginData pluginData
            )
        {
            kind = IdentifierKind.Plugin;

            //
            // VIRTUAL: Id of the deepest derived class.
            //
            id = AttributeOps.GetObjectId(this);

            //
            // VIRTUAL: Group of the deepest derived class.
            //
            group = AttributeOps.GetObjectGroup(this);

            //
            // NOTE: Is the supplied plugin data valid?
            //
            if (pluginData != null)
            {
                EntityOps.MaybeSetGroup(
                    this, pluginData.Group);

                name         = pluginData.Name;
                description  = pluginData.Description;
                flags        = pluginData.Flags;
                clientData   = pluginData.ClientData;
                version      = pluginData.Version;
                uri          = pluginData.Uri;
                appDomain    = pluginData.AppDomain;
                assembly     = pluginData.Assembly;
                assemblyName = pluginData.AssemblyName;
                fileName     = pluginData.FileName;
                typeName     = pluginData.TypeName;
            }

            //
            // NOTE: Are we going to use their command list or create an
            //       entirely new list?
            //
            if ((pluginData != null) && (pluginData.Commands != null))
            {
                commands = pluginData.Commands;
            }
            else
            {
                commands = new CommandDataList();
            }

            //
            // NOTE: Are we going to use their policy list or create an
            //       entirely new list?
            //
            if ((pluginData != null) && (pluginData.Policies != null))
            {
                policies = pluginData.Policies;
            }
            else
            {
                policies = new PolicyDataList();
            }

            //
            // NOTE: Are we going to use their command tokens or create an
            //       entirely new list?
            //
            if ((pluginData != null) && (pluginData.CommandTokens != null))
            {
                commandTokens = pluginData.CommandTokens;
            }
            else
            {
                commandTokens = new LongList();
            }

            //
            // NOTE: Are we going to use their command tokens or create an
            //       entirely new list?
            //
            if ((pluginData != null) && (pluginData.FunctionTokens != null))
            {
                functionTokens = pluginData.FunctionTokens;
            }
            else
            {
                functionTokens = new LongList();
            }

            //
            // NOTE: Are we going to use their policy tokens or create an
            //       entirely new list?
            //
            if ((pluginData != null) && (pluginData.PolicyTokens != null))
            {
                policyTokens = pluginData.PolicyTokens;
            }
            else
            {
                policyTokens = new LongList();
            }

            //
            // NOTE: Are we going to use their trace tokens or create an
            //       entirely new list?
            //
            if ((pluginData != null) && (pluginData.TraceTokens != null))
            {
                traceTokens = pluginData.TraceTokens;
            }
            else
            {
                traceTokens = new LongList();
            }

            //
            // NOTE: Are we going to use the resource manager they specified or
            //       create a new one based on the plugin name and assembly?
            //
            if ((pluginData != null) && (pluginData.ResourceManager != null))
            {
                resourceManager = pluginData.ResourceManager;
            }
            else
            {
                //
                // NOTE: If the assembly is null we are probably loaded into an
                //       isolated application domain.  Therefore, in that case,
                //       and only in that case, since we are executing in the
                //       target application domain, load the assembly based on
                //       the assembly name and then use that to create the
                //       resource manager.  However, do not simply set the
                //       assembly field of this plugin to any non-null value
                //       because we do not want to cause issues with the
                //       interpreter plugin manager later.  Also, skip attempts
                //       to create a resource manager if the NoResources flag
                //       has been set on the plugin.
                //
                if (!FlagOps.HasFlags(flags, PluginFlags.NoResources, true))
                {
                    if (assembly != null)
                    {
                        resourceManager = RuntimeOps.NewResourceManager(
                            assembly);
                    }
                    else if (assemblyName != null)
                    {
                        resourceManager = RuntimeOps.NewResourceManager(
                            assemblyName);
                    }
                }
            }

            //
            // NOTE: Are we going to use the auxiliary data they specified or
            //       create a new one?
            //
            if ((pluginData != null) && (pluginData.AuxiliaryData != null))
            {
                auxiliaryData = pluginData.AuxiliaryData;
            }
            else
            {
                if (!FlagOps.HasFlags(
                        flags, PluginFlags.NoAuxiliaryData, true))
                {
                    auxiliaryData = new ObjectDictionary();
                }
            }

            //
            // NOTE: Also store the plugin token (which may be zero at this
            //       point).
            //
            if (pluginData != null)
            {
                token = pluginData.Token;
            }
        }