Exemplo n.º 1
0
        protected override void ReadValue(PsdReader reader, object userData, out IProperties value)
        {
            Properties props = new Properties();

            int count = reader.ReadInt32();

            List<DescriptorStructure> dss = new List<DescriptorStructure>();

            for (int i = 0; i < count; i++)
            {
                string s = reader.ReadAscii(4);
                string k = reader.ReadAscii(4);
                var c = reader.ReadByte();
                var p = reader.ReadBytes(3);
                var l = reader.ReadInt32();
                var p2 = reader.Position;
                var ds = new DescriptorStructure(reader);
                dss.Add(ds);
                reader.Position = p2 + l;
            }

            props["Items"] = dss;

            value = props;
        }
Exemplo n.º 2
0
        protected override void ReadValue(PsdReader reader, object userData, out IProperties value)
        {
            value = new Properties();

            short version = reader.ReadInt16();
            int count = reader.ReadInt16();

            for (int i = 0; i < count; i++)
            {
                string _8bim = reader.ReadAscii(4);
                string effectType = reader.ReadAscii(4);
                int size = reader.ReadInt32();
                long p = reader.Position;

                switch (effectType)
                {
                    case "dsdw":
                        {
                            //ShadowInfo.Parse(reader);
                        }
                        break;
                    case "sofi":
                        {
                            //this.solidFillInfo = SolidFillInfo.Parse(reader);
                        }
                        break;
                }

                reader.Position = p + size;
            }
        }
Exemplo n.º 3
0
        public static HttpExtend.HttpHeader GetResponse(IProperties properties)
        {
            HttpExtend.HttpHeader command = new HttpExtend.HttpHeader();

            command.Properties = properties.ToHeaders();
            return command;
        }
 /// <summary>
 /// Notifies the plugin that a blog post was successfully published.
 /// </summary>
 /// <param name="dialogOwner">Owner for any dialog boxes shown.</param>
 /// <param name="properties">Property-set that the plugin can use to get and set properties for this post.</param>
 /// <param name="publishingContext">Publishing context for HTML generation.</param>
 /// <param name="publish">If false, the post was posted as a draft.</param>
 public virtual void OnPostPublish(
     IWin32Window dialogOwner,
     IProperties properties,
     IPublishingContext publishingContext,
     bool publish)
 {
 }
 public void LoadEditor(IProperties imageServiceSettings)
 {
     _loadedState = ControlState.Loading;
     _imageServiceSettings = imageServiceSettings;
     LoadEditor();
     _loadedState = ControlState.Loaded;
 }
Exemplo n.º 6
0
        protected override void ReadValue(PsdReader reader, object userData, out IProperties value)
        {
            Properties props = new Properties();

            int version = reader.ReadInt32();
            if (version == 6)
            {
                var r1 = reader.ReadInt32();
                var r2 = reader.ReadInt32();
                var r3 = reader.ReadInt32();
                var r4 = reader.ReadInt32();
                string text = reader.ReadString();
                var count = reader.ReadInt32();

                List<IProperties> slices = new List<IProperties>(count);
                for (int i = 0; i < count; i++)
                {
                    slices.Add(ReadSliceInfo(reader));
                }
            }
            {
                var descriptor = new DescriptorStructure(reader) as IProperties;

                var items = descriptor["slices.Items[0]"] as object[];
                List<IProperties> slices = new List<IProperties>(items.Length);
                foreach (var item in items)
                {
                    slices.Add(ReadSliceInfo(item as IProperties));
                }
                props["Items"] = slices.ToArray();
            }

            value = props;
        }
        public PropertiesItemViewModel(string name, IProperties properties, TreeViewItemViewModel parent)
            : base(parent)
        {
            this.name = name;
            foreach (var item in properties)
            {
                object value = item.Value;

                if (value is IProperties == true)
                {
                    this.Children.Add(new PropertiesItemViewModel(item.Key, value as IProperties, this));
                }
                else if (value is IEnumerable == true && value is string == false)
                {
                    int index = 0;
                    foreach (var i in value as IEnumerable)
                    {
                        string n = string.Format("{0}[{1}]", item.Key, index);
                        if (i is IProperties == true)
                            this.Children.Add(new PropertiesItemViewModel(n, i as IProperties, this));
                        else
                            this.Children.Add(new PropertiesItemViewModel(n, i, this));
                        index++;
                    }
                }
                else
                {
                    this.Children.Add(new PropertiesItemViewModel(item.Key, value, this));
                }
            }
        }
            public GeneralProjectOptionsWidget(IProperties CustomizationObject)
                : base("Base.glade", "GeneralProjectOptionsPanel")
            {
                this.project = (Project)((IProperties)CustomizationObject).GetProperty("Project");

                nameLabel.UseUnderline = true;

                descriptionLabel.UseUnderline = true;

                projectNameEntry.Text = project.Name;
                projectDescriptionTextView.Buffer.Text = project.Description;
                enableViewStateCheckButton.Active = project.EnableViewState;

                switch (project.NewFileSearch)
                {
                case NewFileSearch.None:
                    newFilesOnLoadCheckButton.Active = false;
                    autoInsertNewFilesCheckButton.Active = false;
                    break;
                case NewFileSearch.OnLoad:
                    newFilesOnLoadCheckButton.Active = true;
                    autoInsertNewFilesCheckButton.Active = false;
                    break;
                default:
                    newFilesOnLoadCheckButton.Active = true;
                    autoInsertNewFilesCheckButton.Active = true;
                    break;
                }

                newFilesOnLoadCheckButton.Clicked += new EventHandler(AutoLoadCheckBoxCheckedChangeEvent);
                AutoLoadCheckBoxCheckedChangeEvent(null, null);
            }
Exemplo n.º 9
0
 public static HttpExtend.HttpHeader Get(string appName, IProperties properties)
 {
     HttpExtend.HttpHeader command = new HttpExtend.HttpHeader();
     command.Action = COMMAND_GET + " " + appName;
     command.Properties = properties.ToHeaders();
     return command;
 }
		public DefaultTextEditorProperties()
		{

			properties = ((IProperties)propertyService.GetProperty("NetFocus.DataStructure.TextEditor.Document.DefaultDocumentProperties", new DefaultProperties()));
			FontContainer.DefaultFont = FontContainer.ParseFont(properties.GetProperty("DefaultFont", new Font("Courier New", 10).ToString()));
			properties.PropertyChanged += new PropertyEventHandler(CheckFontChange);
		}
Exemplo n.º 11
0
        public override bool OnPrePublish(IWin32Window dialogOwner, IProperties properties,
                                          IPublishingContext publishingContext, bool publish)
        {
            var info = (BlogPost) publishingContext.PostInfo;

            //look at the publish date.
            if (!info.HasDatePublishedOverride)
            {
                var nextPubDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
                nextPubDate = GetNextDayOccurrence(DayOfWeek.Tuesday, nextPubDate);

                var reader = new JsonTextReader(reader: File.OpenText("Plugins\\Throttle.json"));
                var json = new Newtonsoft.Json.JsonSerializer();

                var config = json.Deserialize<Configuration>(reader);
                var wrapper = new MetaWeblogWrapper(config.Url, config.Username, config.Password);
                List<Post> recentPosts = wrapper.GetRecentPosts(10).ToList();
                while (recentPosts.Any(p => p.DateCreated >= nextPubDate && p.DateCreated < nextPubDate.AddDays(1)))
                {
                    nextPubDate = GetNextDayOccurrence(DayOfWeek.Tuesday, nextPubDate.AddDays(1));
                }
                var pubDate = new DateTime(nextPubDate.Year, nextPubDate.Month, nextPubDate.Day, 9, 0, 0);
                info.DatePublished = pubDate;
                info.DatePublishedOverride = pubDate;
            }
            return base.OnPrePublish(dialogOwner, properties, publishingContext, publish);
        }
		public static string GenerateTypeMetricText(IProperties item)
		{
			if(item is NamespaceProperties){
				
				return GenerateNamespaceMetricText((NamespaceProperties)item).ToString();
				
			} else if (item is MethodProperties) {
				
				return GenerateMethodMetricText((MethodProperties)item).ToString();
				
			} else if (item is ClassProperties) {
				
				return GenerateClassMetricText((ClassProperties)item).ToString();
				
			} else if (item is InterfaceProperties) {
				
				return GenerateInterfaceMetricText((InterfaceProperties)item).ToString();
				
			} else if (item is EnumProperties) {
				
				return GenerateEnumMetricText((EnumProperties)item).ToString();
				
			} else if (item is DelegateProperties) {
				
				return GenerateDelegateMetricText((DelegateProperties)item).ToString();
				
			} else if (item is StructProperties) {
				
				return GenerateStructMetricText((StructProperties)item).ToString();
			
			}
			
			return "NULL";
		}
            public CombineConfigurationPanelWidget(IProperties CustomizationObject)
                : base("Base.glade", "CombineConfigurationsPanel")
            {
                configuration = (CombineConfiguration)((IProperties)CustomizationObject).GetProperty("Config");

                store = new TreeStore (typeof(object), typeof(string), typeof(bool), typeof(string));
                configsList.Model = store;
                configsList.HeadersVisible = true;

                TreeViewColumn col = new TreeViewColumn ();
                CellRendererText sr = new CellRendererText ();
                col.PackStart (sr, true);
                col.Expand = true;
                col.AddAttribute (sr, "text", 1);
                col.Title = "Solution Item";
                configsList.AppendColumn (col);

                CellRendererToggle tt = new CellRendererToggle ();
                tt.Activatable = true;
                tt.Toggled += new ToggledHandler (OnBuildToggled);
                configsList.AppendColumn ("Build", tt, "active", 2);
                configsList.AppendColumn ("Configuration", new CellRendererText (), "text", 3);

                foreach (CombineConfigurationEntry ce in configuration.Entries)
                    store.AppendValues (ce, ce.Entry.Name, ce.Build, ce.ConfigurationName);
            }
 public void AddSettings(IProperties settings)
 {
     foreach (string key in settings.Names)
     {
         SetString(key, settings[key]);
     }
 }
		/// <summary>
		/// Retrieves the value from the given control
		/// </summary>
		/// <param name="control">Editor control</param>
		/// <param name="value">Value to set</param>
		/// <param name="pluginProperties">Plugin properties</param>
		/// <returns>Value</returns>
		public override void SetValueToControl(Control control, object value, IProperties pluginProperties)
		{
			ComboBox comboBox = control as ComboBox;
			FillItems(comboBox, (value ?? string.Empty).ToString().Trim(), true,
				control.Parent.Controls.OfType<TextBox>().SingleOrDefault(c => c.Tag == Options.CustomLanguagesOption),
				Options.StandardLanguageListItems, Options.CustomLanguagesOption, pluginProperties);
		}
Exemplo n.º 16
0
        protected override void ReadValue(PsdReader reader, object userData, out IProperties value)
        {
            Properties props = new Properties();

            int version = reader.ReadInt32();

            if (version != 1)
                throw new InvalidFormatException();

            props["HorizontalGrid"] = reader.ReadInt32();
            props["VerticalGrid"] = reader.ReadInt32();

            int guideCount = reader.ReadInt32();

            List<int> hg = new List<int>();
            List<int> vg = new List<int>();

            for (int i = 0; i < guideCount; i++)
            {
                int n = reader.ReadInt32();
                byte t = reader.ReadByte();

                if (t == 0)
                    vg.Add(n);
                else
                    hg.Add(n);
            }

            props["HorizontalGuides"] = hg.ToArray();
            props["VerticalGuides"] = vg.ToArray();

            value = props;
        }
 private void CopySettings(IProperties sourceSettings, IProperties targetSettings)
 {
     foreach (string key in sourceSettings.Names)
     {
         targetSettings.SetString(key, sourceSettings.GetString(key, null));
     }
 }
Exemplo n.º 18
0
		public PropertyEventArgs(IProperties properties, string key, object oldValue, object newValue)
		{
			this.properties = properties;
			this.key        = key;
			this.oldValue   = oldValue;
			this.newValue   = newValue;
		}
Exemplo n.º 19
0
 public IProperties Register(IProperties properties)
 {
     lock (mGroups)
     {
         TestProperties tp = new TestProperties();
         tp.FromHeaders(properties.ToHeaders());
         Group group = mGroups.Find(e => e.Name == tp.Group);
         if (group == null)
         {
             group = new Group();
             group.Name = tp.Group;
             group.Nodes = new List<Node>();
             group.Nodes.Add(new Node { Name = tp.Node, Host = tp.Host, Port = tp.Port, LastTrackTime=DateTime.Now });
             mGroups.Add(group);
         }
         else
         {
             Node node = group.Nodes.Find(n =>  n.Name== tp.Node );
             if(node !=null)
                 node.LastTrackTime = DateTime.Now;
             else
                 group.Nodes.Add(new Node { Name = tp.Node, Host = tp.Host, Port = tp.Port, LastTrackTime = DateTime.Now });
         }
         return new Properties();
     }
 }
Exemplo n.º 20
0
 public void AdjustOriginalSize(IProperties properties, ref Size size)
 {
     CropDecoratorSettings settings = new CropDecoratorSettings(properties);
     Rectangle? rect = settings.CropRectangle;
     if (rect != null)
         size = rect.Value.Size;
 }
 public ImageDecoratorEditorContextImpl(IProperties settings, ApplyDecoratorCallback applyDecoratorCallback, ImagePropertiesInfo imageProperties, IUndoUnitFactory undoHost, CommandManager commandManager)
 {
     _applyDecoratorCallback = applyDecoratorCallback;
     _settings = settings;
     _imageProperties = imageProperties;
     _undoHost = undoHost;
     _commandManager = commandManager;
 }
 /// <summary>
 /// Notifies the plugin that a post publish operation is about to be attempted,
 /// unless this plugin or another publishing notification plugin cancels the
 /// attempt.
 /// </summary>
 /// <param name="dialogOwner">Owner for any dialog boxes shown.</param>
 /// <param name="properties">Property-set that the plugin can use to get and set properties for this post.</param>
 /// <param name="publishingContext">Publishing context for HTML generation.</param>
 /// <param name="publish">If false, the post is being posted as a draft.</param>
 /// <returns>False to cancel the publish operation, otherwise true.</returns>
 public virtual bool OnPrePublish(
     IWin32Window dialogOwner,
     IProperties properties,
     IPublishingContext publishingContext,
     bool publish)
 {
     return true;
 }
		/// <summary>
		/// Creates an editor control
		/// </summary>
		/// <param name="parentControl">Parent Control</param>
		/// <param name="value">Option value</param>
		/// <param name="pluginProperties">Plugin properties</param>
		/// <returns>Control</returns>
		public override Control CreateEditorControl(Control parentControl, object value, IProperties pluginProperties)
		{
			CustomTextBox textBox = new CustomTextBox();
			textBox.Text = value.ToString();
			textBox.Name = FullName;
			textBox.Pasted += (s, e) => textBox.Text = Utils.RemoveLineWhiteSpaces(textBox.Text, true, true, true);
			textBox.Leave += (s, e) => textBox.Text = Utils.RemoveLineWhiteSpaces(textBox.Text, true, true, true);
			return textBox;
		}
Exemplo n.º 24
0
        public override void Initialize( IProperties pluginOptions )
        {
            base.Initialize(pluginOptions);

            String path = Assembly.GetExecutingAssembly().Location;
            System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(path);

            m_config = config.GetSection("GeSHiConfig") as Configuration.GeSHiConfigSection;
        }
Exemplo n.º 25
0
        public override bool OnPrePublish(System.Windows.Forms.IWin32Window dialogOwner, IProperties properties, IPublishingContext publishingContext, bool publish)
        {
            bool Result = false;        //用于告诉Live Writer是否要post到当前帐户
            if (Posting) return true;   //由于向Server执行Post操作(IBlogClient.NewPost)会递归调用此过程,所以此处需要屏蔽后续的进入尝试

            BlogPost postinfo = publishingContext.PostInfo as BlogPost;
            BlogPostCategory[] categories = null;// = postinfo.Categories.Clone() as BlogPostCategory[];

            //选择帐户
            DialogBlogSelect.InitCategorys((publishingContext.PostInfo as WindowsLive.Writer.Extensibility.BlogClient.BlogPost).Categories);
            if (DialogBlogSelect.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                Posting = false;
                return false;
            }

            //排除当前帐户——当前帐户让Live Writer去完成
            for (int i = 0; i < DialogBlogSelect.SelectedBlogs.Count; i++)
            {
                if (DialogBlogSelect.SelectedBlogs[i].ID.ToString() == publishingContext.AccountId)
                {
                    postinfo.Categories = DialogBlogSelect.SelectedBlogs[i].PostCatalogs.ToArray();
                    DialogBlogSelect.SelectedBlogs.RemoveAt(i);
                    Result = true;
                    break;
                }
            }

            //发送到选择的所有帐户——所有的Post操作共用一个PostInfo对象,需要先备份PostInfo中的目录列表
            if(Result)
            {
                categories = postinfo.Categories.Clone() as BlogPostCategory[];
            }

            foreach (AccountItem blog in DialogBlogSelect.SelectedBlogs)
            {
                string str;
                XmlDocument document;
                BlogSettings settings = BlogSettings.ForBlogId(blog.ID);
                IBlogClient client = BlogClientManager.CreateClient(settings);
                postinfo.Categories = blog.PostCatalogs.ToArray();
                string postId = client.NewPost(settings.HostBlogId, postinfo, NullNewCategoryContext.Instance, true, out str, out document);
                OpenPostedPage(settings.HomepageUrl, postinfo.Permalink);
            }

            //恢复目录列表
            if(Result)
            {
                postinfo.Categories = categories;
            }

            Posting = false;
            return Result;
        }
		/// <summary>
		/// Creates an editor control
		/// </summary>
		/// <param name="parentControl">Parent Control</param>
		/// <param name="value">Option value</param>
		/// <param name="pluginProperties">Plugin properties</param>
		/// <returns>Control</returns>
		public override Control CreateEditorControl(Control parentControl, object value, IProperties pluginProperties)
		{
			NumericUpDown upDown = new NumericUpDown();
			upDown.Increment = 1;
			upDown.Minimum = MinValue;
			upDown.Maximum = MaxValue;
			upDown.Value = (int)value;

			upDown.Name = FullName;
			return upDown;
		}
Exemplo n.º 27
0
        protected override void ReadValue(PsdReader reader, object userData, out IProperties value)
        {
            Properties props = new Properties(5);

            props["Version"] = reader.ReadInt32();
            props["HasCompatibilityImage"] = reader.ReadBoolean();
            props["WriterName"] = reader.ReadString();
            props["ReaderName"] = reader.ReadString();
            props["FileVersion"] = reader.ReadInt32();

            value = props;
        }
		/// <summary>
		/// Fills the combo box items
		/// </summary>
		/// <param name="comboBox"></param>
		/// <param name="selectedValue"></param>
		/// <param name="handleCustomTextChange"></param>
		/// <param name="customOptionsTextBox"></param>
		/// <param name="standardOptions"></param>
		/// <param name="customOption"></param>
		/// <param name="pluginProperties"></param>
		protected virtual void FillItems(ComboBox comboBox, string selectedValue, bool handleCustomTextChange, TextBox customOptionsTextBox, IEnumerable<ListItem> standardOptions, Option customOption, IProperties pluginProperties)
		{
			// Clear
			ListItem selectedItem = comboBox.SelectedItem as ListItem;
			comboBox.Items.Clear();

			// List Items
			List<ListItem> listItems = new List<ListItem>();

			// Add Standard Options
			listItems.AddRange(standardOptions.OrderBy(p => p.Text));

			// Custom Items
			if (customOptionsTextBox != null)
			{
				listItems.AddRange((customOption.GetValueFromControl(customOptionsTextBox) as ListItem[]).OrderBy(p => p.Text));
			}
			else
			{
				listItems.AddRange((customOption.GetValue(pluginProperties) as ListItem[]).OrderBy(p => p.Text));
			}

			// Add
			comboBox.Items.AddRange(listItems.ToArray());

			// Selection
			ListItem newSelectedItem = null;
			selectedValue = (selectedValue ?? string.Empty).Trim();
			if (selectedValue.Length > 0)
			{
				newSelectedItem = listItems.FirstOrDefault(p => string.Equals(p.Value, selectedValue, StringComparison.Ordinal));
			}
			if ((newSelectedItem == null) && (selectedItem != null))
			{
				newSelectedItem = listItems.FirstOrDefault(p => string.Equals(p.Value, selectedItem.Value, StringComparison.Ordinal));
			}
			if (newSelectedItem == null)
			{
				newSelectedItem = listItems.FirstOrDefault(p => string.Equals(p.Value, DefaultValue.ToString(), StringComparison.Ordinal));
			}

			// Set selection
			comboBox.SelectedItem = newSelectedItem ?? listItems.FirstOrDefault();

			// Change handler
			if (handleCustomTextChange && (customOptionsTextBox != null))
			{
				customOptionsTextBox.TextChanged += (s, e) =>
				{
					FillItems(comboBox, null, false, customOptionsTextBox, standardOptions, customOption, pluginProperties);
				};
			}
		}
Exemplo n.º 29
0
 public TrackerInfo GetInfo(IProperties properties)
 {
     TrackerInfo result = new TrackerInfo();
     result.TypeName = "Beetle.Tracker.TestImpl.Group,Beetle.Tracker.TestImpl";
     TestProperties tp = new TestProperties();
     tp.FromHeaders(properties.ToHeaders());
     Group group = mGroups.Find(e => e.Name == tp.Group);
     if (group == null)
         return null;
     result.Data= Formater.ToStringValue(group);
     return result;
 }
Exemplo n.º 30
0
 public AppHost GetHost(IProperties properties =null)
 {
     if(properties ==null)
     {
         properties = new Properties();
     }
     HttpExtend.HttpHeader request = Protocol.Get(mAppName, properties);
     HttpExtend.HttpHeader result = mNode.Send<HttpExtend.HttpHeader>(request);
     if (result.RequestType == "500")
         throw new Exception(result.ActionDetail);
     return new AppHost { Host=result["Host"],Port=int.Parse(result["Port"]) };
 }
Exemplo n.º 31
0
        void _TreeView_SelectedItemChanged(object sender, System.EventArgs e)
        {
            if (_TreeView.SelectedItem == null)
            {
                IProperties selected = InspectorProperties.GetSelected();
                if (selected != null)
                {
                    if (selected is TrackTreeViewItem || selected is TrackTreeViewGroup)
                    {
                        InspectorProperties.Select(null);
                    }
                }
            }
            if (_TreeView.SelectedItem is IProperties)
            {
                InspectorProperties.Select((IProperties)_TreeView.SelectedItem);
            }

            _BtnAddKey.IsEnabled = _TreeView.SelectedItem != null;
        }
Exemplo n.º 32
0
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            config = properties as DisableAdapterProperties;
            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;
            //NetWorkList();
            if (NetWorkState(config.NICname))
            {
                if (!DisableNetWork(NetWork(config.NICname)))
                {
                    throw new BaseException("禁用网卡失败");
                }
                log.Info("禁用网卡成功");
            }
            else
            {
                log.Info(string.Format("未找到该网卡:{0},网卡已禁用", config.NICname));
            }
        }
Exemplo n.º 33
0
        private static void LoadProperties(object instance, IProperties properties)
        {
            var propertiesKeys = properties.Keys;

            foreach (var property in instance.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
                     .Where(p => p.CanWrite &&
                            (p.PropertyType.IsPrimitive || p.PropertyType == typeof(string)) ||
                            p.PropertyType.IsNullableOfAnyPrimitiveType()))
            {
                var key = ExtractKey(property, propertiesKeys);

                if (key is null)
                {
                    continue;
                }

                var value = properties[key];
                SetPropertyValueFromString(instance, property, value);
            }
        }
Exemplo n.º 34
0
        /// <summary>
        /// Creates Wrapper
        /// </summary>
        /// <param name="label">Wrapped label</param>
        /// <param name="icon">Icon</param>
        /// <param name="changeSize">The "change size" sign</param>
        /// <returns>Wrapper</returns>
        internal static UserControlLabel CreateLabel(IObjectLabel label, object icon, bool changeSize)
        {
            UserControlLabel l = new UserControlLabel();

            if (changeSize)
            {
                if (label is Control)
                {
                    Control c = label as Control;
                    if (c.Width > l.panelCenter.Width)
                    {
                        l.Width += c.Width - l.panelCenter.Width;
                    }
                    if (c.Height > l.panelCenter.Height)
                    {
                        l.Height += c.Height - l.panelCenter.Height;
                    }
                }
            }
            Image ic = icon as Image;

            if (ic == null)
            {
                if (label is INonstandardLabel)
                {
                    INonstandardLabel nl = label as INonstandardLabel;
                    ic = nl.Image as Image;
                }
            }
            l.icon = ic;
            l.pictureBoxIcon.Image = l.image;
            IProperties p = l;

            p.Properties = label;
            if (label is Control)
            {
                Control c = label as Control;
                c.Parent = l.panelCenter;
            }
            return(l);
        }
Exemplo n.º 35
0
        //private string pattern;

        //public ReverseNumberExecuter()
        //{
        //    this.pattern = GlobalVaribles.PATTERN;
        //}

        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            config = properties as ReverseNumberProperties;
            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;
            try
            {
                string number = configGv.Get(config.PreGlobalVariable);
                //string mac = configGv.Get(GlobalVaribles.MAC);
                byte[] byteMac = strToToHexByte(number);
                Array.Reverse(byteMac);

                string reverseMac = byteToHexStr(byteMac);
                configGv.Add(config.AfterGlobalVariable, reverseMac);

                log.Info(string.Format("倒序16进制Number成功:{0}", reverseMac));
            }
            catch (Exception ex)
            {
                throw new BaseException(string.Format("倒序16进制Number转换失败,{0}", ex));
            }


            //string reverseMac = mac.Substring(0, 12);
            //string reScanLabelMac = reScanLabel.Substring(12, 12);


            //string macLabel = configGv.Get(GlobalVaribles.MAC);
            //if (!(reScanLabelFixedPart == config.FixedPart))
            //{
            //    throw new BaseException(string.Format("重扫标签的固定部分:{0}与标准固定部分:{1}不一致", reScanLabelFixedPart, config.FixedPart));
            //}
            //log.Info(string.Format("重扫标签的固定部分:{0}与标准固定部分:{1}一致", reScanLabelFixedPart, config.FixedPart));

            //if (!(reScanLabelMac == macLabel))
            //{
            //    throw new BaseException(string.Format("重扫标签的MAC部分:{0}与标签MAC:{1}不一致", reScanLabelMac, macLabel));
            //}
            //log.Info(string.Format("重扫标签的MAC部分:{0}与标签MAC:{1}一致", reScanLabelMac, macLabel));
        }
Exemplo n.º 36
0
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            //config = properties as FindDeviceProperties;
            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;
            //int ret = -1;
            //string returnString = "";

            //取存储的关键字为MoudleBtMac的value值
            string moudleBtMac   = configGv.Get(GlobalVaribles.MAC);
            string btMacFromImes = configGv.Get(GlobalVaribles.LABEL_SN);; //configGv.Get("MAC_BT");

            if (moudleBtMac != btMacFromImes)
            {
                //log.Fail(string.Format("再次扫码的标签一致性检查:\r\n第一次标签 MAC:{0}\r\n第二次标签MAC:{1} 不一致 FAIL\r\n", moudleBtMac, btMacFromImes));
                throw new BaseException(string.Format("再次扫码的标签一致性检查:\r\n第一次标签 MAC:{0}\r\n第二次标签MAC:{1} \r\n不一致 \r\n", moudleBtMac, btMacFromImes));
            }
            //string moudleBtMac = configGv.Get("");
            log.Info(string.Format("再次扫码的标签一致性检查:\r\n第一次标签 MAC:{0}\r\n第二次标签MAC:{1} \r\n一致 \r\n", moudleBtMac, btMacFromImes));
        }
Exemplo n.º 37
0
        private void OnRegister(Beetle.IChannel channel, string appName, IProperties properties)
        {
            IAppTrackerHandler appHandler;
            HttpHeader         result;
            IProperties        ips;

            appHandler = GetAppHandler(appName);
            if (appHandler == null)
            {
                result        = new HttpHeader();
                result.Action = RESULT_STATE_500 + string.Format(ERROR_MSG_TRACKER_NOTFOUND, appName);
                channel.Send(result);
            }
            else
            {
                ips           = appHandler.Register(properties);
                result        = this.GetResponse(ips);
                result.Action = RESULT_STATE_200;
                channel.Send(result);
            }
        }
Exemplo n.º 38
0
        /// <summary>
        /// Construct work context, for values that are not known to be immutable, shallow copies are made
        /// </summary>
        /// <param name="cv">correlation vector</param>
        /// <param name="tag">code location tag</param>
        /// <param name="workContainer">container</param>
        /// <param name="properties">properties (optional)</param>
        /// <param name="cancellationToken">Cancellation token</param>
        public WorkContext(
            CorrelationVector cv,
            Tag tag,
            ILifetimeScope workContainer,
            IProperties properties = null,
            CancellationToken?cancellationToken = null,
            IEventLog eventLog          = null,
            IEventDimensions dimensions = null
            )
        {
            Verify.IsNotNull(nameof(cv), cv);
            Verify.IsNotNull(nameof(tag), tag);

            Cv                = cv;
            Tag               = tag;
            Container         = workContainer;
            Properties        = (properties?.ToDictionary(x => x.Key, x => x.Value) ?? new Dictionary <string, object>()).AsTypeOrDefault <IProperties>();
            CancellationToken = cancellationToken ?? CancellationToken.None;
            EventLog          = eventLog ?? new EventLogNull();
            Dimensions        = dimensions ?? new Dictionary <string, string>().AsTypeOrDefault <IEventDimensions>();
        }
Exemplo n.º 39
0
        protected override void ReadValue(PsdReader reader, object userData, out IProperties value)
        {
            Properties props = new Properties();

            while (reader.Position < this.EndPosition)
            {
                reader.ValidateSignature();

                string resourceID = reader.ReadInt16().ToString();
                string name       = reader.ReadPascalString(2);
                long   length     = reader.ReadInt32();
                length += (length % 2);

                ResourceReaderBase resourceReader = ReaderCollector.CreateReader(resourceID, reader, length);
                string             resourceName   = ReaderCollector.GetDisplayName(resourceID);

                props[resourceName] = resourceReader;
            }

            value = props;
        }
Exemplo n.º 40
0
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            //config = properties as FindDeviceProperties;
            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;
            //int ret = -1;
            //string returnString = "";

            //取存储的关键字为MoudleBtMac的value值
            string moudleBtMac   = configGv.Get("MoudleBtMac");
            string btMacFromImes = configGv.Get("MAC_BT");; //configGv.Get("MAC_BT");

            if (moudleBtMac != btMacFromImes)
            {
                log.Fail(string.Format("BT MAC核验:读出BT MAC:{0},与预写入MAC:{1} 不一致 FAIL\r\n", moudleBtMac, btMacFromImes));
                throw new BaseException(string.Format("BT MAC核验:读出BT MAC:{0},与预写入MAC:{1} 不一致 \r\n", moudleBtMac, btMacFromImes));
            }
            //string moudleBtMac = configGv.Get("");
            log.Info(string.Format("BT MAC核验:读出BT MAC:{0},与预写入MAC:{1} 一致,PASS \r\n", moudleBtMac, btMacFromImes));
        }
Exemplo n.º 41
0
        // Just an alternative syntax!

        /// <summary>
        /// Return the object value associated with the provided property key as dynamic.
        /// </summary>
        /// <typeparam name="TKey">The type of the property key.</typeparam>
        /// <typeparam name="TValue">The type of the property value.</typeparam>
        /// <param name="IProperties">An object implementing IProperties.</param>
        /// <param name="Key">The property key.</param>
        public static dynamic GetDynamicProperty <TKey, TValue>(this IProperties <TKey, TValue> IProperties, TKey Key)
            where TKey : IEquatable <TKey>, IComparable <TKey>, IComparable
        {
            #region Initial checks

            if (IProperties == null)
            {
                throw new ArgumentNullException("The given IProperties must not be null!");
            }

            #endregion

            TValue _Value;

            if (IProperties.TryGetProperty(Key, out _Value))
            {
                return((dynamic)_Value);
            }

            return(default(TValue));
        }
Exemplo n.º 42
0
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            //config = properties as CheckBtRssiProperties;
            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;
            config   = properties as LogMacChangeToThisMacProperties;
            try
            {
                //string strBtMac = configGv.Get("MAC_BT");
                //string strMoudleBtMac = configGv.Get("MoudleBtMac");
                //if (string.IsNullOrEmpty(strBtMac) && !string.IsNullOrEmpty(strMoudleBtMac))
                //{
                //    configGv.Add("MAC", strMoudleBtMac);
                //}
                //else if (!string.IsNullOrEmpty(strBtMac) && !string.IsNullOrEmpty(strMoudleBtMac))//有标签BT MAC,则肯定经过一致性检查
                //{
                //    configGv.Add("MAC", strMoudleBtMac);
                //}
                //else if (!string.IsNullOrEmpty(strBtMac) && string.IsNullOrEmpty(strMoudleBtMac))//有标签BT MAC,则肯定经过一致性检查
                //{
                //    configGv.Add("MAC", strBtMac);
                //}
                //else
                //{
                //    log.Fail(string.Format("LOG MAC设置为BT MAC失败\r\n,取号BT MAC{0},模块BT MAC:{1} \r\n", strBtMac, strMoudleBtMac));
                //}
                string strMoudleBtMac = configGv.Get(config.GlobalVarible);
                if (string.IsNullOrEmpty(strMoudleBtMac))
                {
                    throw new Exception("要设置的MAC为空");
                }
                configGv.Add("MAC", strMoudleBtMac);
                log.Info(string.Format("LOG MAC设置为:\r\n{0} PASS \r\n", strMoudleBtMac));
            }
            catch (Exception ex)
            {
                throw new Exception("LOG MAC设置出错," + ex.Message);
            }
        }
Exemplo n.º 43
0
        internal static IProperties AutoMap <T>(this IProperties existingProperties, IPropertyVisitor visitor = null, int maxRecursion = 0)
            where T : class
        {
            var properties     = new Properties();
            var autoProperties = new PropertyWalker(typeof(T), visitor, maxRecursion).GetProperties();

            foreach (var autoProperty in (IEnumerable <KeyValuePair <PropertyName, IProperty> >)autoProperties)
            {
                properties[autoProperty.Key] = autoProperty.Value;
            }

            // Existing/manually mapped properties always take precedence
            if (existingProperties != null)
            {
                foreach (var existing in (IEnumerable <KeyValuePair <PropertyName, IProperty> >)existingProperties)
                {
                    properties[existing.Key] = existing.Value;
                }
            }

            return(properties);
        }
Exemplo n.º 44
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="properties"></param>
        /// <param name="propName"></param>
        /// <param name="propValue"></param>
        private void SetWIAProperty(IProperties properties, object propName, object propValue)
        {
            Property prop = properties.get_Item(ref propName);

            try
            {
                prop.set_Value(ref propValue);
            }
            catch
            {
                // DPI can only be set to values listed in SubTypeValues
                // This sets the DPI to the lowest one supported by the scanner
                if (propName.ToString() == WIA_HORIZONTAL_SCAN_RESOLUTION_DPI || propName.ToString() == WIA_VERTICAL_SCAN_RESOLUTION_DPI)
                {
                    foreach (object test in prop.SubTypeValues)
                    {
                        prop.set_Value(test);
                        break;
                    }
                }
            }
        }
Exemplo n.º 45
0
        public static void Select(IProperties p)
        {
            if (_Instance == null)
            {
                _Instance = UnityEngine.ScriptableObject.CreateInstance <InspectorProperties>();
            }

            if (_Instance._SelectedObject != p)
            {
                if (_Instance._SelectedObject != null)
                {
                    _Instance._SelectedObject.IsSelectedProperties = false;
                }
            }

            _Instance._SelectedObject = p;

            if (p != null)
            {
                UnityEditor.Selection.activeObject = _Instance;
            }
        }
Exemplo n.º 46
0
        public static int GetAsInteger(IProperties properties, string key, int defaultValue)
        {
            object r = properties[key];

            if (null == r)
            {
                return(defaultValue);
            }

            if (r.GetType() == typeof(int))
            {
                return((int)r);
            }

            int value = 0;

            if (int.TryParse(r.ToString(), out value))
            {
                return(value);
            }
            return(defaultValue);
        }
Exemplo n.º 47
0
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            config = properties as EnableAdapterProperties;
            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;
            //NetWorkList();
            if (NetWorkState(config.NICname))
            {
                if (!EnableNetWork(NetWork(config.NICname)))
                {
                    throw new BaseException(string.Format("开启网卡:{0},失败", config.NICname));
                }
                log.Info(string.Format("开启网卡:{0},成功", config.NICname));
            }
            else
            {
                log.Info(string.Format("未找到该网卡:{0},网卡已启用", config.NICname));
            }

            //EnableAdapter(out mac, config.NICname);
        }
Exemplo n.º 48
0
        protected override void ReadValue(PsdReader reader, object userData, out IProperties value)
        {
            Properties props = new Properties();

            int version = reader.ReadInt32();

            if (version != 1)
            {
                throw new InvalidFormatException();
            }

            props["HorizontalGrid"] = reader.ReadInt32();
            props["VerticalGrid"]   = reader.ReadInt32();

            int guideCount = reader.ReadInt32();

            List <int> hg = new List <int>();
            List <int> vg = new List <int>();

            for (int i = 0; i < guideCount; i++)
            {
                int  n = reader.ReadInt32();
                byte t = reader.ReadByte();

                if (t == 0)
                {
                    vg.Add(n);
                }
                else
                {
                    hg.Add(n);
                }
            }

            props["HorizontalGuides"] = hg.ToArray();
            props["VerticalGuides"]   = vg.ToArray();

            value = props;
        }
Exemplo n.º 49
0
        public static object ApplyProperties(this MethodInfo method, object thisArg, IProperties properties)
        {
            if (method == null)
            {
                throw new ArgumentNullException(nameof(method));
            }

            properties = properties ?? Properties.Empty;
            var methodParameters = method.GetParameters();
            var parms            = new object[methodParameters.Length];
            int paramIndex       = 0;

            if (method.IsStatic)
            {
                if (methodParameters.Length == 0)
                {
                    throw RuntimeFailure.ApplyPropertiesStaticMethodRequiresArg("method");
                }
                if (thisArg == null)
                {
                    throw new ArgumentNullException(nameof(thisArg));
                }
                parms[0]   = thisArg;
                paramIndex = 1;
                if (!methodParameters[0].ParameterType.IsInstanceOfType(thisArg))
                {
                    throw RuntimeFailure.ThisArgumentIncorrectType(thisArg.GetType());
                }
            }

            for (; paramIndex < methodParameters.Length; paramIndex++)
            {
                var pi = methodParameters[paramIndex];
                parms[paramIndex] = properties.GetProperty(pi.Name);
            }

            return(method.Invoke(thisArg, parms));
        }
Exemplo n.º 50
0
        private void HandleEvents()
        {
            Event e = Event.current;

            if (e != null && e.type != EventType.Used)
            {
                if (e.type == EventType.KeyDown)
                {
                    if (e.keyCode == KeyCode.Delete)
                    {
                        IProperties p = InspectorProperties.GetSelected();
                        if (p != null)
                        {
                            if (p is KeyView)
                            {
                                ((BaseTrackBar)(((KeyView)p).TrackBar)).Delete((KeyView)p);
                                e.Use();
                            }
                            else if (p is TrackTreeViewItem)
                            {
                                e.Use();
                                _TracksTreeView.DeleteTrack((TrackTreeViewItem)p);
                            }
                            else if (p is TrackTreeViewGroup)
                            {
                                e.Use();
                                _TracksTreeView.DeleteGroup((TrackTreeViewGroup)p);
                            }
                        }
                    }
                    else if (e.keyCode == KeyCode.S)
                    {
                        _TracksTreeView.AddKey();
                        e.Use();
                    }
                }
            }
        }
Exemplo n.º 51
0
        /// <summary>
        /// 创建type实例,将properties中的值注入到实例中
        /// </summary>
        /// <returns>创建的实例</returns>
        public static object CreateObjectFromProperites(IProperties properties, Type type, IConvertSystem convertSystem)
        {
            if (null == type)
            {
                return(null);
            }

            if (null == properties)
            {
                return(null);
            }

            if (!type.IsClass && !type.IsValueType)
            {
                return(null);
            }

            if (type.IsAbstract)
            {
                return(null);
            }

            ConstructorInfo constructorInfo = type.GetConstructor(Type.EmptyTypes);

            if (null == constructorInfo)
            {
                return(null);
            }

            object instance = constructorInfo.Invoke(new object[] { });

            foreach (KeyValuePair <string, object> kp in properties)
            {
                invokeSetter(instance, kp.Key, kp.Value, convertSystem);
            }

            return(instance);
        }
Exemplo n.º 52
0
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            config = properties as ShowBtMacQrCodeProperties;
            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;
            //int ret = -1;
            //string returnString = "";

            //取存储的关键字为MoudleBtMac的value值
            string moudleBtMac = configGv.Get("MoudleBtMac");

            QrCodeForm qrCodeForm = new QrCodeForm(moudleBtMac, config.ShowTime);

            qrCodeForm.ShowDialog();
            //if (moudleBtMac != btMacFromImes)
            //{
            //    log.Fail(string.Format("BT MAC核验:读出BT MAC:{0},与预写入MAC:{1} 不一致 FAIL\r\n", moudleBtMac, btMacFromImes));
            //    throw new BaseException(string.Format("BT MAC核验:读出BT MAC:{0},与预写入MAC:{1} 不一致 \r\n", moudleBtMac, btMacFromImes));
            //}
            ////string moudleBtMac = configGv.Get("");
            //log.Info(string.Format("BT MAC核验:读出BT MAC:{0},与预写入MAC:{1} 一致,PASS \r\n", moudleBtMac, btMacFromImes));
        }
Exemplo n.º 53
0
        internal static IProperties AutoMap(this IProperties existingProperties, Type documentType, IPropertyVisitor visitor = null, int maxRecursion = 0)
        {
            var properties     = new Properties();
            var autoProperties = new PropertyWalker(documentType, visitor, maxRecursion).GetProperties();

            foreach (var autoProperty in autoProperties)
            {
                properties[autoProperty.Key] = autoProperty.Value;
            }

            if (existingProperties == null)
            {
                return(properties);
            }

            // Existing/manually mapped properties always take precedence
            foreach (var existing in existingProperties)
            {
                properties[existing.Key] = existing.Value;
            }

            return(properties);
        }
Exemplo n.º 54
0
        public ILogger GetCachedLogger(IProperties properties, Type loggerBeanType)
        {
            ILogger logger = Get(loggerBeanType);

            if (logger != null)
            {
                return(logger);
            }
            Object writeLock = GetWriteLock();

            lock (writeLock)
            {
                logger = Get(loggerBeanType);
                if (logger != null)
                {
                    // Concurrent thread might have been faster
                    return(logger);
                }
                logger = LoggerFactory.GetLogger(loggerBeanType, properties);
                Put(loggerBeanType, logger);
                return(logger);
            }
        }
Exemplo n.º 55
0
        //private List<WIFISSID> ssids=new List<WIFISSID>();
        //private wifiSo wifiso;
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            config = properties as DisConnectSsiProperties;
            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;

            try
            {
                Wifi objWifi = configGv.GetObject("ObjWifi") as Wifi;
                if (objWifi != null)
                {
                    if (objWifi.ConnectionStatus == WifiStatus.Connected)
                    {
                        objWifi.Disconnect();
                        log.Info("断开WIFI连接成功");
                    }
                    else
                    {
                        throw new BaseException(string.Format("未连接WIFI热点,无法断开连接1"));
                    }
                }
                else
                {
                    throw new BaseException(string.Format("未连接WIFI热点,objWifi为空,无法断开连接"));
                }
                //if (!hasSsid)
                //{
                //    throw new BaseException(string.Format("未扫描到SSID:{0}", ssid));

                //}
            }
            catch (Exception ex)
            {
                throw new Exception("断开热点出错," + ex.Message);
            }
        }
        // If no value is present, the value is simply set.
        // If a value is present, and it is a value, the value is converted to
        // an array containing that existing element plus <c>value</c>.
        // If the value located there is a collection of some sort, then
        // the value is added to it.  If the collection is read-only, its
        // contents are copied into a new.
        public static void Push(this IProperties source, string property, object value)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            object current;

            if (source.TryGetProperty(property, out current))
            {
                IEnumerable e = current as IEnumerable;
                if (e == null)
                {
                    source.SetProperty(property, new object[] { current, value });
                }
                else
                {
                    object[] objArray = current as object[];
                    if (objArray != null)
                    {
                        Array.Resize(ref objArray, objArray.Length + 1);
                        objArray[objArray.Length - 1] = value;
                    }
                    else
                    {
                        List <object> items = new List <object>(e.Cast <object>());
                        items.Add(value);
                        source.SetProperty(property, items.ToArray());
                    }
                }
            }
            else
            {
                source.SetProperty(property, value);
            }
        }
Exemplo n.º 57
0
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)
        {
            FormTipAndUartCheckProperties config = properties as FormTipAndUartCheckProperties;
            ILog          log        = globalDic.Get <ILog>();
            List <ComDut> comDutList = globalDic[typeof(List <ComDut>).ToString()] as List <ComDut>;

            if (comDutList == null || comDutList.Count == 0)
            {
                throw new BaseException("COM为空");
            }
            ComDut comDut = null;

            foreach (var item in comDutList)
            {
                if (item.PortName == config.PortName)
                {
                    comDut = item;
                    break;
                }
            }
            if (comDut == null)
            {
                throw new BaseException(string.Format("ComDut No PortName:{0}", config.PortName));
            }


            TipAndCheckUartForm formUserConfirm = new TipAndCheckUartForm(config, log, comDut)
            {
            };

            formUserConfirm.ShowDialog();

            if (!formUserConfirm.Result)
            {
                throw new BaseException("Fail");
            }
        }
Exemplo n.º 58
0
        //private List<WIFISSID> ssids=new List<WIFISSID>();
        //private wifiSo wifiso;
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            config = properties as SocketDisConnectProperties;
            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;

            try
            {
                Socket objSocket = configGv.GetObject("ObjSocket") as Socket;
                if (objSocket != null)
                {
                    if (objSocket.Connected)
                    {
                        //objSocket.Disconnect(true);
                        objSocket.Close();
                        if (objSocket.Connected)
                        {
                            throw new BaseException(string.Format("断开连接失败,状态仍然为连接状态"));
                        }
                        log.Info("断开Soket连接成功");
                    }
                    else
                    {
                        throw new BaseException(string.Format("未连接Soket服务器,无法断开连接1"));
                    }
                }
                else
                {
                    throw new BaseException(string.Format("未连接Soket服务器,objSocket为空,无法断开连接"));
                }
            }
            catch (Exception ex)
            {
                throw new Exception("断开Soket连接出错," + ex.Message);
            }
        }
Exemplo n.º 59
0
        /// <summary>
        /// Assign the given IDictionary to the IProperties object.
        /// If a value already exists for a key, then the previous key/value is overwritten.
        /// </summary>
        /// <typeparam name="TKey">The type of the property key.</typeparam>
        /// <typeparam name="TValue">The type of the property value.</typeparam>
        /// <param name="IProperties">An object implementing IProperties.</param>
        /// <param name="IDictionary">A IDictionary of type TKey and TValue</param>
        public static IProperties <TKey, TValue> SetProperties <TKey, TValue>(this IProperties <TKey, TValue> IProperties, IDictionary <TKey, TValue> IDictionary)
            where TKey : IEquatable <TKey>, IComparable <TKey>, IComparable
        {
            #region Initial checks

            if (IProperties == null)
            {
                throw new ArgumentNullException("The given IProperties must not be null!");
            }

            if (IDictionary == null)
            {
                throw new ArgumentNullException("The given dictionary must not be null!");
            }

            #endregion

            foreach (var _KeyValuePair in IDictionary)
            {
                IProperties.Set(_KeyValuePair.Key, _KeyValuePair.Value);
            }

            return(IProperties);
        }
Exemplo n.º 60
0
        public void Run(IProperties properties, GlobalDic <string, object> globalDic)//virtual
        {
            ILog log = globalDic[typeof(ILog).ToString()] as ILog;

            configGv = globalDic[typeof(GlobalVaribles).ToString()] as GlobalVaribles;
            //取存储的关键字为MoudleBtMac的value值
            string DevWifi_MAC = configGv.Get("DevWifi_MAC");
            string DevBt_MAC   = configGv.Get("DevBt_MAC");

            DevWifi_MAC = DevWifi_MAC.Replace(":", "").Replace(":", "").ToUpper();
            DevBt_MAC   = DevBt_MAC.Replace(":", "").Replace(":", "").ToUpper();
            if (Convert.ToInt64(DevWifi_MAC, 16) + 1 != Convert.ToInt64(DevBt_MAC, 16))
            {
                throw new BaseException(string.Format("WIFI MAC:{0},BT MAC:{1} 非+1关系,未通过校验 FAIL\r\n", DevWifi_MAC, DevBt_MAC));
            }
            log.Info(string.Format(string.Format("WIFI MAC:{0},BT MAC:{1} 通过 +1关系校验 PASS\r\n", DevWifi_MAC, DevBt_MAC)));

            string labelMAC = configGv.Get(GlobalVaribles.MAC);

            if (string.IsNullOrEmpty(labelMAC))
            {
                configGv.Add(GlobalVaribles.MAC, DevWifi_MAC);
            }
        }