コード例 #1
0
ファイル: ExtensionManager.cs プロジェクト: sh4nnongoh/Dynamo
        /// <summary>
        /// Removes an extension from the current session.
        /// </summary>
        /// <param name="extension">Extension</param>
        public void Remove(IExtension extension)
        {
            var fullName = extension.Name + " (id: " + extension.UniqueId + ")";
            if (!extensions.Contains(extension))
            {
                Log("ExtensionManager does not contain " + fullName + " extension");
                return;
            }

            extensions.Remove(extension);
            try
            {
                extension.Dispose();
            }
            catch (Exception ex)
            {
                Log(fullName + " extension cannot be disposed properly: " + ex.Message);
            }

            Log(fullName + " extension is removed");
            if (ExtensionRemoved != null)
            {
                ExtensionRemoved(extension);
            }
        }
コード例 #2
0
 public void RegisterViews(IExtension owner, params View[] views)
 {
     foreach (var v in views)
     {
         RegisterView(owner, v);
     }
 }
コード例 #3
0
        public SongRequestsWindow(IExtension sender)
        {
            extension = sender;

            InitializeComponent();

            ini = SongRequest.ini; new Settings(extension, "Settings.ini");

            UI.CenterSpacer(RequestingRulesLabel, RequestingRulesSpacer, false, true);

            ChargeRequest.Text = "Requesting costs                       " + Currency.Name;

            ini.SetValue("Settings", "ChargeRequest", (ChargeRequest.Checked = (ini.GetValue("Settings", "ChargeRequest", "1") == "1")) ? "1" : "0");
            int variable = Convert.ToInt32(ini.GetValue("Settings", "RequestPrice", "25"));
            if (variable > RequestPrice.Maximum || variable < RequestPrice.Minimum)
            {
                variable = 25;
            }
            ini.SetValue("Settings", "RequestPrice", (RequestPrice.Value = variable).ToString());
            ini.SetValue("Settings", "LimitRequests", (LimitRequests.Checked = (ini.GetValue("Settings", "LimitRequests", "1") == "1")) ? "1" : "0");
            variable = Convert.ToInt32(ini.GetValue("Settings", "RequestsLimit", "2"));
            if (variable > RequestsLimit.Maximum || variable < RequestsLimit.Minimum)
            {
                variable = 2;
            }
            ini.SetValue("Settings", "RequestsLimit", (RequestsLimit.Value = variable).ToString());
        }
コード例 #4
0
ファイル: GetPackage.cs プロジェクト: ExRam/DotSpatial-PCL
 public IPackage GetPackageFromExtension(IExtension extension)
 {
     string id = extension.AssemblyQualifiedName.Substring(0, extension.AssemblyQualifiedName.IndexOf(',')); // Grab the part prior to the first comma
     id = id.Substring(0, id.LastIndexOf('.')); // Grab the part prior to the last period
     var pack = packages.GetLocalPackage(id);
     return pack;
 }
コード例 #5
0
        /// <inheritdoc />
        public void Assign(IReflectExtensionProperties reflector, IExtension extension, IConsumeConfiguration consumer, IHaveConversionCallbacks conversionCallbacksProvider, IHaveDefaultConversionCallback defaultConversionCallbackProvider)
        {
            Ensure.ArgumentNotNull(reflector, "reflector");
            Ensure.ArgumentNotNull(consumer, "consumer");
            Ensure.ArgumentNotNull(conversionCallbacksProvider, "conversionCallbacksProvider");
            Ensure.ArgumentNotNull(defaultConversionCallbackProvider, "defaultConversionCallbackProvider");

            var properties = reflector.Reflect(extension).ToList();
            IDictionary<string, IConversionCallback> conversionCallbacks = conversionCallbacksProvider.ConversionCallbacks;
            IConversionCallback defaultCallback = defaultConversionCallbackProvider.DefaultConversionCallback;

            foreach (KeyValuePair<string, string> keyValuePair in consumer.Configuration)
            {
                KeyValuePair<string, string> pair = keyValuePair;

                var matchedProperty = properties.SingleOrDefault(property => property.Name.Equals(pair.Key, StringComparison.OrdinalIgnoreCase));

                if (matchedProperty == null)
                {
                    continue;
                }

                IConversionCallback conversionCallback;
                if (!conversionCallbacks.TryGetValue(pair.Key, out conversionCallback))
                {
                    conversionCallback = defaultCallback;
                }

                matchedProperty.SetValue(extension, conversionCallback.Convert(pair.Value, matchedProperty), null);
            }
        }
コード例 #6
0
        public ExtensionProviderExtensionsTest()
        {
            this.provider = A.Fake<IExtensionProvider<IExtension>>();
            this.extension = A.Fake<IExtension>();

            this.exception = new Exception();
        }
コード例 #7
0
        /// <inheritdoc />
        public void Assign(IReflectExtensionProperties reflector, IExtension extension, IConsumeConfiguration consumer, IHaveConversionCallbacks callbackProvider)
        {
            Ensure.ArgumentNotNull(reflector, "reflector");
            Ensure.ArgumentNotNull(consumer, "consumer");
            Ensure.ArgumentNotNull(callbackProvider, "callbackProvider");

            IEnumerable<PropertyInfo> properties = reflector.Reflect(extension);
            IDictionary<string, Func<string, PropertyInfo, object>> conversionCallbacks = callbackProvider.ConversionCallbacks;
            Func<string, PropertyInfo, object> defaultCallback = callbackProvider.DefaultConversionCallback;

            foreach (KeyValuePair<string, string> keyValuePair in consumer.Configuration)
            {
                KeyValuePair<string, string> pair = keyValuePair;

                var matchedProperty = properties.Where(property => property.Name.Equals(pair.Key, StringComparison.OrdinalIgnoreCase))
                    .SingleOrDefault();

                if (matchedProperty == null)
                {
                    continue;
                }

                Func<string, PropertyInfo, object> conversionCallback;
                if (!conversionCallbacks.TryGetValue(pair.Key, out conversionCallback))
                {
                    conversionCallback = defaultCallback;
                }

                matchedProperty.SetValue(extension, conversionCallback(pair.Value, matchedProperty), null);
            }
        }
コード例 #8
0
ファイル: GiveawaysWindow.cs プロジェクト: carriercomm/ModBot
        public GiveawaysWindow(IExtension sender)
        {
            InitializeComponent();

            ini = new Settings(sender, "Settings.ini", "[Default]");

            UI.CenterSpacer(GiveawayTypeLabel, GiveawayTypeSpacer);
            UI.CenterSpacer(GiveawaySettingsLabel, GiveawaySettingsSpacer, false, true);
            UI.CenterSpacer(GiveawayBansLabel, GiveawayBansSpacer);
            UI.CenterSpacer(GiveawayUsersLabel, GiveawayUsersSpacer);

            Panel panel = new Panel();
            panel.Size = new Size(1, 1);
            panel.Location = new Point(GiveawayTypeSpacer.Location.X + GiveawayTypeSpacer.Size.Width - 1, GiveawayTypeSpacer.Location.Y + 9);
            Controls.Add(panel);
            panel.BringToFront();
            panel = new Panel();
            panel.Size = new Size(1, 1);
            panel.Location = new Point(GiveawayBansSpacer.Location.X + GiveawayBansSpacer.Size.Width - 1, GiveawayBansSpacer.Location.Y + 9);
            Controls.Add(panel);
            panel.BringToFront();
            /*panel.BackColor = Color.Black;
            panel.Size = new Size(Giveaway_AddPresent.Size.Width + Giveaway_RemovePresent.Size.Width, 1);
            panel.Location = new Point(Giveaway_AddPresent.Location.X, Giveaway_AddPresent.Location.Y + 1);
            Controls.Add(panel);
            panel.BringToFront();*/
        }
コード例 #9
0
ファイル: GetPackage.cs プロジェクト: hanchao/DotSpatial
 public IPackage GetPackageFromExtension(IExtension extension)
 {
     string id = extension.AssemblyQualifiedName.Substring(0, extension.AssemblyQualifiedName.IndexOf(',')); // Grab the part prior to the first comma
     if (id.Contains("."))
         id = id.Substring(0, id.LastIndexOf('.')); // Grab the part prior to the last period, only if id contains period (Changed by JLeiss)
     var pack = packages.GetLocalPackage(id);
     return pack;
 }
コード例 #10
0
ファイル: Gambling.cs プロジェクト: carriercomm/ModBot
        public static void Load(IExtension sender)
        {
            extension = sender;

            Events.Connected += Events_Connected;
            Events.Currency.OnQueue += Events_OnCurrencyQueue;
            Events.OnDisconnect += Events_OnDisconnect;
        }
コード例 #11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ConsumeConfiguration"/> class.
        /// </summary>
        /// <param name="extension">The extension.</param>
        public ConsumeConfiguration(IExtension extension)
        {
            var consumeConfiguration = extension as IConsumeConfiguration;

            this.Configuration = consumeConfiguration != null
                ? consumeConfiguration.Configuration
                : new Dictionary<string, string>();
        }
コード例 #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HaveConversionCallbacks"/> class.
        /// </summary>
        /// <param name="extension">The extension.</param>
        public HaveConversionCallbacks(IExtension extension)
        {
            var callbacksProvider = extension as IHaveConversionCallbacks;

            this.ConversionCallbacks = callbacksProvider != null
                ? callbacksProvider.ConversionCallbacks
                : new Dictionary<string, IConversionCallback>();
        }
コード例 #13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HaveDefaultConversionCallback"/> class.
        /// </summary>
        /// <param name="extension">The extension.</param>
        public HaveDefaultConversionCallback(IExtension extension)
        {
            var callbacksProvider = extension as IHaveDefaultConversionCallback;

            this.DefaultConversionCallback = callbacksProvider != null
                ? callbacksProvider.DefaultConversionCallback
                : new DefaultConversionCallback();
        }
コード例 #14
0
 public void SendMessage(IExtension sender, string receiver, string command, params object[] arguments)
 {
     if(sender==null)
         throw new ArgumentNullException(nameof(sender));
     if (_extensions.ContainsKey(receiver))
     {
         _extensions[receiver].ExtensionMessageReceived(sender,command,arguments);
     }
 }
コード例 #15
0
ファイル: Host.cs プロジェクト: CassieEllen/opensim
        //private Scene m_scene;

        public Host(IObject m_obj, Scene m_scene, IExtension m_extend, IMicrothreader m_threader)
        {
            this.m_obj = m_obj;
            this.m_threader = m_threader;
            this.m_extend = m_extend;
            //this.m_scene = m_scene;

            m_graphics = new Graphics(m_scene);
        }
コード例 #16
0
ファイル: Host.cs プロジェクト: kow/Aurora-Sim
        //private Scene m_scene;

        public Host (IObject m_obj, IScene m_scene, IExtension m_extend)
        {
            this.m_obj = m_obj;
            this.m_extend = m_extend;

            m_graphics = new Graphics(m_scene);

            m_scene.EventManager.OnFrame += EventManager_OnFrame;
        }
コード例 #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LoadConfigurationSection"/> class.
 /// </summary>
 /// <param name="extension">The extension.</param>
 public LoadConfigurationSection(IExtension extension)
 {
     var loader = extension as ILoadConfigurationSection;
     this.sectionProvider =
         section =>
         loader != null
             ? loader.GetSection(section)
             : (ConfigurationSection)ConfigurationManager.GetSection(section);
 }
コード例 #18
0
ファイル: Host.cs プロジェクト: JohnMcCaffery/XMRM
        //private Scene m_scene;
        public Host(IObject obj, Scene scene, IExtension extend, IMicrothreader threader)
        {
            this.m_obj = obj;
            this.m_threader = new MicrothreaderWrapper(threader);
            this.m_extend = new ExtensionWrapper(extend);
            //this.m_scene = m_scene;

            m_graphics = new GraphicsWrapper(new Graphics(scene, this));
        }
コード例 #19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HaveConfigurationSectionName"/> class.
        /// </summary>
        /// <param name="extension">The extension.</param>
        public HaveConfigurationSectionName(IExtension extension)
        {
            Ensure.ArgumentNotNull(extension, "extension");

            var namer = extension as IHaveConfigurationSectionName;

            this.SectionName = namer != null
                ? namer.SectionName
                : extension.GetType().Name;
        }
 internal static IExtension GetExtension()
 {
     if (s_extension == null)
     {
         UID extID = new UIDClass();
         extID.Value = ThisAddIn.IDs.CurveByInferenceExtension;
         s_extension = ArcMap.Application.FindExtensionByCLSID(extID);
     }
     return s_extension;
 }
コード例 #21
0
 public void ExtensionMessageReceived(IExtension sender, string command, object[] arguments)
 {
     switch (command)
     {
         case "WriteLine":
             if (arguments.Length > 0)
                 WriteLine(arguments[0]);
             break;
     }
 }
コード例 #22
0
		/// <summary>
		/// Adds a new extension to this client session.
		/// </summary>
		public virtual void AddExtension(IExtension extension)
		{
			if (null != extension)
			{
				lock (_extensions)
				{
					if (!_extensions.Contains(extension))
						_extensions.Add(extension);
				}
			}
		}
コード例 #23
0
		/// <summary>
		/// Removes an existing extension from this client session.
		/// </summary>
		public virtual void RemoveExtension(IExtension extension)
		{
			if (null != extension)
			{
				lock (_extensions)
				{
					if (_extensions.Contains(extension))
						_extensions.Remove(extension);
				}
			}
		}
コード例 #24
0
        /// <summary>
        /// Initializes a new instance of the <see cref="HaveConversionCallbacks"/> class.
        /// </summary>
        /// <param name="extension">The extension.</param>
        public HaveConversionCallbacks(IExtension extension)
        {
            var callbacksProvider = extension as IHaveConversionCallbacks;

            this.ConversionCallbacks = callbacksProvider != null
                ? callbacksProvider.ConversionCallbacks
                : new Dictionary<string, Func<string, PropertyInfo, object>>();

            this.DefaultConversionCallback = callbacksProvider != null
                ? callbacksProvider.DefaultConversionCallback
                : DefaultCallback;
        }
コード例 #25
0
ファイル: View.cs プロジェクト: chienhao10/FinalesFunkeln
        public View(IExtension owner, string name, string internalName, UIElement ui)
        {
            if (name == null)
                throw new ArgumentNullException(nameof(name));
            if(internalName==null)
                throw new ArgumentNullException(nameof(internalName));
            if(ui==null)
                throw new ArgumentNullException(nameof(ui));
            Name = name;
            InternalName = internalName;
            Ui = ui;

        }
コード例 #26
0
ファイル: Giveaways.cs プロジェクト: carriercomm/ModBot
        public static void Load(IExtension sender)
        {
            extension = sender;

            UI.AddWindow("Giveaway", Window = new GiveawaysWindow(extension));

            Events.Connected += Events_Connected;
            Events.Channel.ModeratorsChecked += Events_ModeratorsChecked;
            Events.Chat.MessageReceived += Events_MessageReceived;
            Events.Users.Added += Events_UserAdded;
            Events.Users.Removed += Events_UserRemoved;
            Events.OnDisconnect += Events_OnDisconnect;
        }
コード例 #27
0
ファイル: IExtension.cs プロジェクト: TalasZh/opencbs
        public ExtensionInfo(IExtension extension)
        {
            _extensionName = extension.GetMeta("Name");

            Type extensionType = extension.GetType();
            _guid = extension.Guid;

            Assembly extensionAssembly = extensionType.Assembly;
            _version = extensionAssembly.GetName().Version.ToString(3);
            _filePath = extensionAssembly.Location;
            FileInfo fileInfo = new FileInfo(_filePath);
            _fileSize = fileInfo.Length;
            _vendor = extension.GetMeta("Vendor");
        }
コード例 #28
0
        public void Remove(IExtension extension)
        {
            var fullName = extension.Name + " (id: " + extension.UniqueId + ")";
            if (!extensions.Contains(extension))
            {
                Log("ExtensionManager does not contain " + fullName + " extension");
                return;
            }

            extensions.Remove(extension);
            extension.Dispose();
            Log(fullName + " extension is removed");
            if (ExtensionRemoved != null)
            {
                ExtensionRemoved(extension);
            }
        }
コード例 #29
0
ファイル: ExtensionManager.cs プロジェクト: sh4nnongoh/Dynamo
        /// <summary>
        /// Adds an extension to the current session.
        /// </summary>
        /// <param name="extension">Extension</param>
        public void Add(IExtension extension)
        {
            var fullName = extension.Name + " (id: " + extension.UniqueId + ")";
            if (extensions.Find(ext => ext.UniqueId == extension.UniqueId) == null)
            {
                extensions.Add(extension);
                Log(fullName + " extension is added");

                if (ExtensionAdded != null)
                {
                    ExtensionAdded(extension);
                }
            }
            else
            {
                Log("Could not add a duplicate of " + fullName);
            }
        }
コード例 #30
0
 public int Serialize(IExtension extension)
 {
     if (extension == null) return 0;
     Stream stream = extension.BeginAppend();
     try
     {
         SerializationContext ctx = new SerializationContext(stream, null);
         int len = Serialize(ctx);
         ctx.Flush();
         extension.EndAppend(stream, true);
         return len;
     }
     catch
     {
         extension.EndAppend(stream, false);
         throw;
     }
 }
コード例 #31
0
ファイル: ExtensibleUtil.cs プロジェクト: yhz9999/xRAT
        internal static void AppendExtendValue(TypeModel model, IExtensible instance, int tag, DataFormat format,
                                               object value)
        {
#if FEAT_IKVM
            throw new NotSupportedException();
#else
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }

            // TODO
            //model.CheckTagNotInUse(tag);

            // obtain the extension object and prepare to write
            IExtension extn = instance.GetExtensionObject(true);
            if (extn == null)
            {
                throw new InvalidOperationException("No extension object available; appended data would be lost.");
            }
            bool   commit = false;
            Stream stream = extn.BeginAppend();
            try
            {
                using (ProtoWriter writer = new ProtoWriter(stream, model, null))
                {
                    model.TrySerializeAuxiliaryType(writer, null, format, tag, value, false);
                    writer.Close();
                }
                commit = true;
            }
            finally
            {
                extn.EndAppend(stream, commit);
            }
#endif
        }
コード例 #32
0
ファイル: Extensions.cs プロジェクト: tranpl/statemachine
        public void BeforeExecutingEntryActionsHierarchical(
            AsyncPassiveStateMachine<string, string> machine,
            IExtension<string, string> extension)
        {
            "establish an extension".x(()
                => extension = A.Fake<IExtension<string, string>>());

            "establish a hierarchical state machine using the extension".x(async () =>
            {
                machine = new AsyncPassiveStateMachine<string, string>(Name);

                machine.AddExtension(extension);

                machine.DefineHierarchyOn("A")
                    .WithHistoryType(HistoryType.None)
                    .WithInitialSubState("A0");

                machine.In("0")
                    .On("A0").Goto("A0");

                await machine.Initialize("0");
                await machine.Start();
            });

            "when firing an event onto the state machine".x(()
                => machine.Fire("A0"));

            "it should call EnteringState on registered extensions for entered super states of target state".x(()
                => A.CallTo(() => extension.EnteringState(
                        A<IStateMachineInformation<string, string>>.That.Matches(x => x.Name == Name && x.CurrentStateId == "A0"),
                        A<IState<string, string>>.That.Matches(x => x.Id == "A"),
                        A<ITransitionContext<string, string>>.That.Matches(x => x.EventId.Value == "A0")))
                    .MustHaveHappened());

            "it should call EnteringState on registered extensions for entered leaf target state".x(()
                => A.CallTo(() => extension.EnteringState(
                        A<IStateMachineInformation<string, string>>.That.Matches(x => x.Name == Name && x.CurrentStateId == "A0"),
                        A<IState<string, string>>.That.Matches(x => x.Id == "A0"),
                        A<ITransitionContext<string, string>>.That.Matches(x => x.EventId.Value == "A0")))
                    .MustHaveHappened());
        }
コード例 #33
0
        protected ArrayList createInstances(Assembly assembly)
        {
            Type[]    types      = assembly.GetTypes();
            ArrayList res        = new ArrayList();
            Type      pluginType = typeof(IExtension);

            foreach (Type t in types)
            {
                if (pluginType.IsAssignableFrom(t))
                {
                    ConstructorInfo cons = t.GetConstructor(Type.EmptyTypes);
                    if (cons != null)
                    {
                        IExtension p = (IExtension)cons.Invoke(null);
                        res.Add(p);
                    }
                }
            }

            return(res);
        }
コード例 #34
0
        /// <summary>
        /// Loads the extensions.
        /// </summary>
        /// <exception cref="ConfigurationItemMissingException"></exception>
        /// <exception cref="InvalidExtensionException">
        /// </exception>
        public void LoadExtensions()
        {
            IConfigurationSection[] extensionConfigurations = _config.GetSections(EXTENSION_CONFIGURATION_KEY).ToArray();
            if (extensionConfigurations.Length == 0)
            {
                return;
            }

            HashSet <IExtension> extensions = new HashSet <IExtension>();

            foreach (IConfigurationSection extensionConfiguration in extensionConfigurations)
            {
                string name = extensionConfiguration.Key;
                string path = _config.Get($"{extensionConfiguration.Path}:path");

                _logger.Debug($"Loading extension: {name}");

                if (string.IsNullOrEmpty(path) || !File.Exists(path))
                {
                    throw new ConfigurationItemMissingException($"{extensionConfiguration.Path}:path");
                }

                LoadAssembly(path, name);
            }

            foreach (var extensionType in _extensionTypes)
            {
                IExtension extension = Activator.CreateInstance(extensionType.Key.AsType(), extensionType.Value, _dependencyUtility) as IExtension;
                if (extension == null)
                {
                    throw new InvalidExtensionException(extensionType.Value, extensionType.Key.AssemblyQualifiedName);
                }

                extension.Initialize();

                extensions.Add(extension);
            }

            Extensions = extensions;
        }
コード例 #35
0
        public int Serialize(IExtension extension)
        {
            if (extension == null)
            {
                return(0);
            }
            Stream stream = extension.BeginAppend();

            try
            {
                SerializationContext ctx = new SerializationContext(stream, null);
                int len = Serialize(ctx);
                ctx.Flush();
                extension.EndAppend(stream, true);
                return(len);
            }
            catch
            {
                extension.EndAppend(stream, false);
                throw;
            }
        }
コード例 #36
0
        private void Installed_SelectedValueChanged(object sender, EventArgs e)
        {
            IExtension extension = Installed.SelectedItem as IExtension;

            if (extension == null)
            {
                uxUninstall.Enabled = false;
            }
            else
            {
                var package = GetPackageFromExtension(extension);

                if (package == null)
                {
                    uxUninstall.Enabled = false;
                }
                else
                {
                    uxUninstall.Enabled = true;
                }
            }
        }
コード例 #37
0
    void LoadImageAndCircle()
    {
        IsTopGeometryLoaded = false;
        string realPhoto_path = EditorUtility.OpenFilePanel("Load Image", "", "jpg");

        if (realPhoto_path.Length != 0)
        {
            //--------------------------------------------------------------------
            // Data Prepare -- Background Image
            Texture2D CanvasMaskRawImg = new Texture2D(4, 4);
            if (File.Exists(realPhoto_path))
            {
                m_MaskRawImg     = new Image <Rgb, byte>(realPhoto_path);
                CanvasMaskRawImg = ResizeImgWithHeight(m_MaskRawImg, canvasPlane2D.height);
                m_MaskRawImg     = m_MaskRawImg.Resize(CanvasMaskRawImg.width, CanvasMaskRawImg.height, Inter.Linear);

                // Background Image
                backimg.sprite = Sprite.Create(CanvasMaskRawImg, new Rect(0, 0, CanvasMaskRawImg.width, CanvasMaskRawImg.height), Vector2.zero);
                backimg.rectTransform.sizeDelta = new Vector2(CanvasMaskRawImg.width, CanvasMaskRawImg.height);
                IExtension.SetTransparency(backimg, 0.3f);

                //m_engine.m_faceEngine.img = m_MaskRawImg.Convert<Gray, byte>();
                //m_engine.m_faceEngine.imgPath = maskRawImg_path;

                IsTopGeometryLoaded = false;
            }

            // Updata Path
            string folderPath = Path.GetDirectoryName(realPhoto_path);
            string fileName   = Path.GetFileName(realPhoto_path);
            m_engine.m_Img = CanvasMaskRawImg;

            // Load Mesh  Text
            m_engine.LoadMesh(realPhoto_path.Substring(0, realPhoto_path.Length - 4) + ".obj");
            // Save Img
            GraphicsEngine.SaveImg(CanvasMaskRawImg, fileName);
            m_engine.Invoke_CaptureMeshMask();
        }
    }
コード例 #38
0
        /// <summary>
        /// Activates the Switch Windows functional agent to enable the
        /// user to switch windows/apps.  If taskname
        /// is not null, it only shows windows belonging to the task (eg
        /// notepad, word)
        /// </summary>
        /// <param name="taskName">filter by this process name</param>
        public static async void ShowTaskSwitcher(string taskName = "")
        {
            try
            {
                Context.AppTalkWindowManager.CloseTalkWindow();
                IApplicationAgent switchWindowsAgent = Context.AppAgentMgr.GetAgentByName("Switch Windows Agent");
                if (switchWindowsAgent == null)
                {
                    return;
                }

                IExtension extension = switchWindowsAgent;
                extension.GetInvoker().SetValue("FilterByProcessName", taskName);
                await Context.AppAgentMgr.ActivateAgent(switchWindowsAgent as IFunctionalAgent);

                Log.Debug("Returned from activate agent");
            }
            catch (Exception ex)
            {
                Log.Debug(ex.ToString());
            }
        }
コード例 #39
0
ファイル: Program.cs プロジェクト: Zulkir/ClarityWorlds
        private static void Run(string[] args)
        {
            //GenOutput.FillDomain(GenDomain.Static);
            var extensions = new IExtension[]
            {
                new EtoGuiExtension(),
                new OglRenderingExtension(),
                new ItdFormatExtension(),
                new FFmpegVideoExtension(),
                new FluidSimulationExtension(),
                new DicomFormatExtension(),
                new BuildingStoryLayoutExtension(),
                new OalExtension(),
                new PptxImportExtension(),
                new LatexImletExtension(),
                new SpherePackingExtension(),
            };
            var environment  = new DesktopEnvironment(extensions);
            var appLifecycle = new AppLifecycle();

            appLifecycle.StartAndRun(environment);
        }
コード例 #40
0
        public void ClearingExtensions(
            IStateMachine <string, int> machine,
            IExtension <string, int> extension)
        {
            "establish a state machine with an extension".x(() =>
            {
                machine = new PassiveStateMachine <string, int>();

                extension = A.Fake <IExtension <string, int> >();
                machine.AddExtension(extension);
            });

            "when clearing all extensions from the state machine".x(() =>
            {
                machine.ClearExtensions();
                machine.Initialize("initial");
            });

            "it should not anymore notify extension about internal events".x(() =>
                                                                             A.CallTo(extension)
                                                                             .MustNotHaveHappened());
        }
コード例 #41
0
        static byte[] GetExtensionBytes(IExtensible obj)
        {
            Assert.IsNotNull(obj, "null extensible");
            IExtension extn = obj.GetExtensionObject(false);

            Assert.IsNotNull(extn, "no extension object");
            Stream s = extn.BeginQuery();

            try
            {
                using (MemoryStream ms = new MemoryStream()) {
                    int b; // really lazy clone...
                    while ((b = s.ReadByte()) >= 0)
                    {
                        ms.WriteByte((byte)b);
                    }
                    return(ms.ToArray());
                }
            } finally {
                extn.EndQuery(s);
            }
        }
コード例 #42
0
        internal static void AppendExtendValue(TypeModel model, IExtensible instance, int tag, DataFormat format, object value)
        {
            model ??= TypeModel.DefaultModel;
            if (instance is null) ThrowHelper.ThrowArgumentNullException(nameof(instance));
            if (value is null) ThrowHelper.ThrowArgumentNullException(nameof(value));

            // TODO
            //model.CheckTagNotInUse(tag);

            // obtain the extension object and prepare to write
            IExtension extn = instance.GetExtensionObject(true);
            if (extn is null) ThrowHelper.ThrowInvalidOperationException("No extension object available; appended data would be lost.");
            bool commit = false;
            Stream stream = extn.BeginAppend();
            try
            {
                var state = ProtoWriter.State.Create(stream, model, null);
                try
                {
                    model.TrySerializeAuxiliaryType(ref state, null, format, tag, value, false, null, isRoot: false);
                    state.Close();
                }
                catch
                {
                    state.Abandon();
                    throw;
                }
                finally
                {
                    state.Dispose();
                }

                commit = true;
            }
            finally
            {
                extn.EndAppend(stream, commit);
            }
        }
コード例 #43
0
        private static void RegisterExtensionServices(IServiceCollection services, IExtension extension, IConfiguration extensionConfiguration)
        {
            var extensionServiceProviderPaths = extension.GetOptions <string[]>(ExtensionServiceProvidersSectionName);

            if (extensionServiceProviderPaths is null)
            {
                return;
            }

            foreach (var path in extensionServiceProviderPaths)
            {
                try
                {
                    using var assemblyStream = extension.GetFile(path);
                    if (assemblyStream is null)
                    {
                        Console.WriteLine($"ERROR: Could not find extension service provider assembly {path} in extension {extension.Name}");
                        continue;
                    }

                    var assembly         = AssemblyLoadContext.Default.LoadFromStream(assemblyStream);
                    var serviceProviders = assembly.GetTypes()
                                           .Where(t => t.IsPublic && !t.IsAbstract && t.IsAssignableTo(typeof(IExtensionServiceProvider)))
                                           .Select(t => Activator.CreateInstance(t))
                                           .Cast <IExtensionServiceProvider>();

                    foreach (var sp in serviceProviders)
                    {
                        sp.AddServices(new ExtensionServiceConfiguration(services, extensionConfiguration));
                    }
                }
                catch (FileLoadException)
                {
                }
                catch (BadImageFormatException)
                {
                }
            }
        }
コード例 #44
0
        /// <summary>
        /// Displays the task switcher form which is the Alt-Tab
        /// equivalent to switch between application windows. If taskname
        /// is not null, it only shows windows belonging to the task (eg
        /// notepad, word)
        /// </summary>
        /// <param name="taskName">filter by this process name</param>
        public static void ShowTaskSwitcherAltTab(String taskName = "")
        {
            try
            {
                //Context.AppTalkWindowManager.CloseTalkWindow();
                Form taskSwitcherForm = Context.AppPanelManager.CreatePanel("TaskSwitcherForm");
                if (taskSwitcherForm != null)
                {
                    if (!String.IsNullOrEmpty(taskName) && taskSwitcherForm is IExtension)
                    {
                        IExtension extension = taskSwitcherForm as IExtension;
                        extension.GetInvoker().SetValue("FilterProcessName", taskName);
                    }

                    Context.AppPanelManager.ShowDialog(taskSwitcherForm as IPanel);
                }
            }
            catch (Exception e)
            {
                Log.Debug("Error creating task switcher dialog. Exception: " + e);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DependencyTelemetry"/> class by cloning an existing instance.
        /// </summary>
        /// <param name="source">Source instance of <see cref="DependencyTelemetry"/> to clone from.</param>
        private DependencyTelemetry(DependencyTelemetry source)
        {
            if (source.measurementsValue != null)
            {
                Utils.CopyDictionary(source.Metrics, this.Metrics);
            }

            this.context            = source.context.DeepClone();
            this.Sequence           = source.Sequence;
            this.Timestamp          = source.Timestamp;
            this.samplingPercentage = source.samplingPercentage;
            this.successFieldSet    = source.successFieldSet;
            this.extension          = source.extension?.DeepClone();
            this.Name       = source.Name;
            this.Id         = source.Id;
            this.ResultCode = source.ResultCode;
            this.Duration   = source.Duration;
            this.Success    = source.Success;
            this.Data       = source.Data;
            this.Target     = source.Target;
            this.Type       = source.Type;
        }
コード例 #46
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RequestTelemetry"/> class by cloning an existing instance.
        /// </summary>
        /// <param name="source">Source instance of <see cref="RequestTelemetry"/> to clone from.</param>
        private RequestTelemetry(RequestTelemetry source)
        {
            this.Duration = source.Duration;
            this.Id       = source.Id;
            if (source.measurementsValue != null)
            {
                Utils.CopyDictionary(source.Metrics, this.Metrics);
            }

            this.Name                      = source.Name;
            this.context                   = source.context.DeepClone();
            this.ResponseCode              = source.ResponseCode;
            this.Source                    = source.Source;
            this.Success                   = source.Success;
            this.Url                       = source.Url;
            this.Sequence                  = source.Sequence;
            this.Timestamp                 = source.Timestamp;
            this.successFieldSet           = source.successFieldSet;
            this.extension                 = source.extension?.DeepClone();
            this.samplingPercentage        = source.samplingPercentage;
            this.ProactiveSamplingDecision = source.ProactiveSamplingDecision;
        }
コード例 #47
0
ファイル: LectureManagerHandler.cs プロジェクト: angellcq/src
        /// <summary>
        /// Launches the lecture manager.  First launches the
        /// file browser to get lecture file and then launches lecture
        /// manager with the file.
        /// </summary>
        /// <param name="form">scanner form</param>
        private async void launchLectureManager(Form form)
        {
            // First launch the file browser to get
            // the file name from the user
            IApplicationAgent fileBrowserAgent = Context.AppAgentMgr.GetAgentByName("FileBrowser Agent");

            if (fileBrowserAgent == null)
            {
                return;
            }

            fileBrowserAgent.GetInvoker().SetValue("AutoLaunchFile", false);
            fileBrowserAgent.GetInvoker().SetValue("SelectActionOpen", true);
            fileBrowserAgent.GetInvoker().SetValue("Folders", Common.AppPreferences.GetFavoriteFolders());//.AppPreferences.FavoriteFolders.Split(';'));
            fileBrowserAgent.GetInvoker().SetValue("IncludeFileExtensions", new[] { "*.", "txt", "doc", "docx" });
            fileBrowserAgent.GetInvoker().SetValue("ExcludeFileExtensions", getExcludeExtensions());

            await Context.AppAgentMgr.ActivateAgent(fileBrowserAgent as IFunctionalAgent);

            String selectedFile = fileBrowserAgent.GetInvoker().GetStringValue("SelectedFile");

            if (!String.IsNullOrEmpty(selectedFile))
            {
                // now launch lecture manager for the selected file
                IApplicationAgent agent = Context.AppAgentMgr.GetAgentByName("Lecture Manager Agent");
                if (agent != null)
                {
                    Windows.CloseForm(form);
                    IExtension extension = agent as IExtension;
                    extension.GetInvoker().SetValue("LoadFromFile", true);
                    extension.GetInvoker().SetValue("LectureFile", selectedFile);
                    Log.Debug("Invoking LectureManager agent");
                    await Context.AppAgentMgr.ActivateAgent(agent as IFunctionalAgent);

                    Log.Debug("Returned from LectureManager agent");
                }
            }
        }
        public void DisableExtensions(IApplication app)
        {
            try
            {
                IExtensionManager    pExtManager = app as IExtensionManager;
                IExtensionConfig     pExtConfig;
                IJITExtensionManager jitExtManager = app as IJITExtensionManager;


                for (int i = 0; i < pExtManager.ExtensionCount; i++)
                {
                    IExtension ext = pExtManager.Extension[i];
                    pExtConfig = ext as IExtensionConfig;
                    if (pExtConfig != null)
                    {
                        pExtConfig.State = esriExtensionState.esriESDisabled;
                    }
                }
                for (int i = 0; i < jitExtManager.JITExtensionCount; i++)
                {
                    UID        extID = jitExtManager.get_JITExtensionCLSID(i);
                    IExtension ext   = app.FindExtensionByCLSID(extID);

                    if (ext != null)
                    {
                        pExtConfig = ext as IExtensionConfig;
                        if (pExtConfig != null)
                        {
                            pExtConfig.State = esriExtensionState.esriESDisabled;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(String.Format("Extensions could not be released: {0}", ex.Message));
            }
        }
コード例 #49
0
        public static void LoadAssemblyExtensions(Assembly assembly)
        {
            Type[]   constructorParams = new Type[] { };
            object[] parameters        = new object[] { };

            foreach (Type t in assembly.GetTypes())
            {
                try
                {
                    if (t.GetInterface(typeof(IExtension <TOwner>).Name) != null)
                    {
                        ConstructorInfo     info      = t.GetConstructor(constructorParams);
                        IExtension <TOwner> extension = (IExtension <TOwner>)info.Invoke(parameters);
                        Extensions.Add(extension);
                    }
                }
                catch (Exception e)
                {
                    throw new ExtensionException(String.Format(
                                                     "Failed to load IExtension {0} from assembly {1}", t.FullName, assembly.FullName), e);
                }
            }
        }
コード例 #50
0
ファイル: Extensions.cs プロジェクト: lepeap/TxTraktor
 public void NoExtensionsButExtensionsInGrammar()
 {
     Assert.Throws <CfgCompileException>(() =>
     {
         var exts = new IExtension[] {};
         Checker.CheckRules(
             new []
         {
             new RuleSrc("S",
                         new []
             {
                 new RuleItem(
                     RuleItemType.VariableName,
                     "test1")
             },
                         extensionType: "test1",
                         extensionQuery: "test")
         },
             new Rule[] {},
             extensions: exts
             );
     });
 }
コード例 #51
0
        /// <summary>
        /// Occurs when this tool is created
        /// </summary>
        /// <param name="hook">Instance of the application</param>
        public override void OnCreate(object hook)
        {
            if (m_hookHelper == null)
            {
                m_hookHelper = new HookHelperClass();
            }

            m_hookHelper.Hook = hook;

            // TODO:  Add ToolNewDisplacement.OnCreate implementation
            IMapControl2 pMapCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl2;

            //m_NewLineFeedback.Display = pMapCtr.ActiveView.ScreenDisplay;
            //m_FrmVectorLinkTable.OriginPoints = OriginPoints;
            //m_FrmVectorLinkTable.TargetPoints = TargetPoints;
            m_FrmVectorLinkTable.IMUFeatureList             = m_IMUFeatureList;
            m_FrmVectorLinkTable.CenterlinePointFeatureList = m_CenterlinePointFeatureList;
            m_FrmVectorLinkTable.MapCtr = pMapCtr;
            //m_FrmVectorLinkTable.refreshLayer += new RefreshEvent(RefreshLayer);

            if (m_FrmVectorLinkTable != null)
            {
                m_FrmVectorLinkTable.Owner =
                    System.Windows.Forms.Form.FromChildHandle(User32API.GetCurrentWindowHandle()) as System.Windows.Forms.Form;
            }

            IExtensionManager extensionManager = ((IHookHelper2)m_hookHelper).ExtensionManager;
            UID guid = new UIDClass();

            guid.Value = "{E07B4C52-C894-4558-B8D4-D4050018D1DA}"; //Snapping extension.
            IExtension extension = extensionManager.FindExtension(guid);

            m_SnappingEnvironment = extension as ISnappingEnvironment;

            m_snappingFeed = new SnappingFeedbackClass();
            m_snappingFeed.Initialize(hook, m_SnappingEnvironment, true);
        }
コード例 #52
0
        private void SetInterface(Type type, IExtension <T> extension)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }

            if (extension == null)
            {
                throw new ArgumentNullException("extension");
            }

            lock (_sync) {
                var priorExtensionType = (Type)null;

                if (_byname.TryGetValue(type.FullName, out priorExtensionType))
                {
                    if (priorExtensionType == type)
                    {
                        _bytype[type] = extension;
                    }
                    else
                    {
                        _byname[type.FullName] = type;
                        _bytype.Remove(priorExtensionType);
                        _bytype.Add(type, extension);
                    }
                }
                else
                {
                    _byname.Add(type.FullName, type);
                    _bytype.Add(type, extension);
                }

                Interlocked.Increment(ref _revision);
            }
        }
コード例 #53
0
        private void BackupExtension(IExtension extension)
        {
            string path      = GetExtensionPath(extension);
            string directory = "\\" + Path.GetFileName(Path.GetDirectoryName(path)) + "\\";

            //create the backup directory and set the permissions
            string               destinationDirectory = Application.StartupPath + "\\backup\\";
            DirectoryInfo        di   = new DirectoryInfo(destinationDirectory);
            FileSystemAccessRule fsar = new FileSystemAccessRule(
                new SecurityIdentifier(WellKnownSidType.WorldSid, null), FileSystemRights.FullControl,
                InheritanceFlags.ContainerInherit, PropagationFlags.InheritOnly, AccessControlType.Allow);
            DirectorySecurity ds = null;

            if (!di.Exists)
            {
                Directory.CreateDirectory(destinationDirectory);
            }

            ds = di.GetAccessControl();
            ds.AddAccessRule(fsar);

            //create the directory of the extension
            destinationDirectory += directory;
            di = new DirectoryInfo(destinationDirectory);
            ds = null;

            if (!di.Exists)
            {
                Directory.CreateDirectory(destinationDirectory);
            }

            ds = di.GetAccessControl();
            ds.AddAccessRule(fsar);

            File.Copy(path, destinationDirectory + Path.GetFileName(path));
            App.MarkExtensionForRemoval(path);
        }
コード例 #54
0
        /// <summary>
        /// Copies any extension data stored for the instance to the underlying stream
        /// </summary>
        public static void AppendExtensionData(IExtensible instance, ProtoWriter writer, ref State state)
        {
            if (instance == null)
            {
                throw new ArgumentNullException(nameof(instance));
            }
            if (writer == null)
            {
                throw new ArgumentNullException(nameof(writer));
            }
            // we expect the writer to be raw here; the extension data will have the
            // header detail, so we'll copy it implicitly
            if (writer.WireType != WireType.None)
            {
                throw CreateException(writer);
            }

            IExtension extn = instance.GetExtensionObject(false);

            if (extn != null)
            {
                // unusually we *don't* want "using" here; the "finally" does that, with
                // the extension object being responsible for disposal etc
                Stream source = extn.BeginQuery();
                try
                {
                    if (ProtoReader.TryConsumeSegmentRespectingPosition(source, out var data, ProtoReader.TO_EOF))
                    {
                        writer.ImplWriteBytes(ref state, data.Array, data.Offset, data.Count);
                        writer.Advance(data.Count);
                    }
                    else
                    {
                        writer.ImplCopyRawFromStream(ref state, source);
                    }
                }
コード例 #55
0
        private Boolean LocationObjectExtension(IExtension Extension, LocationObject Location)
        {
            if (Equals(Extension, null))
            {
                return(false);
            }
            if (Equals(Location, null))
            {
                return(false);
            }

            if (!Equals(Extension.ExtensionDescriptionAttribute.Name, Location.ExtensionName))
            {
                return(false);
            }
            if (!Equals(Location.ExtensionLanguage, null)) // Only check language if location has one.
            {
                if (!Equals(Extension.ExtensionDescriptionAttribute.Language, Location.ExtensionLanguage))
                {
                    return(false);
                }
            }
            return(true);
        }
コード例 #56
0
        /// <summary>
        /// Handles the Click event of the buttonAddExtension control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        /// <remarks>Documented by Dev08, 2009-07-10</remarks>
        private void buttonAddExtension_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = MLifter.SettingsManager.Properties.Resources.EXTENSION_FILEFILTER;
            if (ofd.ShowDialog().Value)
            {
                ExtensionFile extFile = new ExtensionFile(ofd.FileName);
                extFile.Open(LoginForm.OpenLoginForm);
                Guid extensionId = extFile.Extension.Id;

                if (SettingsManagerLogic.LearningModule.Extensions.Any(ext => ext.Id == extensionId) &&
                    MessageBox.Show(String.Format(MLifter.SettingsManager.Properties.Resources.EXTENSION_REPLACE_TEXT, extFile.Extension.Name),
                                    MLifter.SettingsManager.Properties.Resources.EXTENSION_REPLACE_CAPTION, MessageBoxButton.YesNo, MessageBoxImage.Question) != MessageBoxResult.Yes)
                {
                    return;
                }

                IExtension newExt = SettingsManagerLogic.LearningModule.ExtensionFactory(extFile.Extension.Id);
                extFile.Extension.CopyTo(newExt, null);

                LoadLMExtensions();
            }
        }
コード例 #57
0
        public T[] BuildConfigurationsFromXml <T>(IExtension extension)
            where T : IXmlSerializable, new()
        {
            List <T> result = new List <T>();

            using (XmlReader reader = XmlReader.Create(
                       new StringReader(extension.Configuration), Settings, XmlUtils.CreateParserContext()))
            {
                reader.MoveToContent();

                if (CanReadXml <T>(reader))
                {
                    while (reader.IsStartElement())
                    {
                        string xmlElementName = reader.LocalName;

                        T         instance      = new T();
                        XmlReader subtreeReader = reader.ReadSubtree();
                        subtreeReader.MoveToContent();
                        instance.ReadXml(subtreeReader);
                        ConfigureConfigurationElement(instance, extension);
                        result.Add(instance);

                        if (!reader.IsStartElement())
                        {
                            reader.ReadEndElement();
                        }
                        else
                        {
                            reader.ReadToNextSibling(xmlElementName);
                        }
                    }
                }
            }
            return(result.ToArray());
        }
コード例 #58
0
        /// <summary>
        /// Updates the internal & external body data.
        /// </summary>
        private void SetBody(IExtension data)
        {
            if (RegionTemplate == null)
            {
                using (var db = new DataContext()) {
                    RegionTemplate = db.RegionTemplates.Where(t => t.Id == RegionTemplateId).Single();
                }
            }

            if (!String.IsNullOrEmpty(RegionTemplate.Type))
            {
                var js = new JavaScriptSerializer();
                body = data;

                if (typeof(HtmlString).IsAssignableFrom(ExtensionManager.ExtensionTypes[RegionTemplate.Type]))
                {
                    InternalBody = ((HtmlString)data).ToString();
                }
                else
                {
                    InternalBody = js.Serialize(data);
                }
            }
        }
コード例 #59
0
ファイル: ProtoReader.cs プロジェクト: yonglehou/Symbiote
        /// <summary>
        /// Copies the current field into the instance as extension data
        /// </summary>
        public void AppendExtensionData(IExtensible instance)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }
            IExtension extn   = instance.GetExtensionObject(true);
            bool       commit = false;
            // unusually we *don't* want "using" here; the "finally" does that, with
            // the extension object being responsible for disposal etc
            Stream dest = extn.BeginAppend();

            try
            {
                //TODO: replace this with stream-based, buffered raw copying
                using (ProtoWriter writer = new ProtoWriter(dest, model))
                {
                    AppendExtensionField(writer);
                    writer.Close();
                }
                commit = true;
            }
            finally { extn.EndAppend(dest, commit); }
        }
コード例 #60
0
ファイル: ProtoReader.cs プロジェクト: unseen-code/tianqi_src
        public void AppendExtensionData(IExtensible instance)
        {
            if (instance == null)
            {
                throw new ArgumentNullException("instance");
            }
            IExtension extensionObject = instance.GetExtensionObject(true);
            bool       commit          = false;
            Stream     stream          = extensionObject.BeginAppend();

            try
            {
                using (ProtoWriter protoWriter = new ProtoWriter(stream, this.model, null))
                {
                    this.AppendExtensionField(protoWriter);
                    protoWriter.Close();
                }
                commit = true;
            }
            finally
            {
                extensionObject.EndAppend(stream, commit);
            }
        }