示例#1
0
            public override bool Equals(object obj)
            {
                if (ReferenceEquals(obj, null) || GetType() != obj.GetType())
                {
                    return(false);
                }

                ProfilePath other = (ProfilePath)obj;

                if (ReferenceEquals(_path, other._path))
                {
                    return(true);
                }

                if (_path.Length != other._path.Length)
                {
                    return(false);
                }

                for (int i = 0; i < _path.Length; ++i)
                {
                    if (!_path[i].Equals(other._path[i]))
                    {
                        return(false);
                    }
                }

                return(true);
            }
示例#2
0
            public void SaveValue(ProfilePath path, string value)
            {
                string  name = EncodedPath(path);
                XmlNode node = _document.DocumentElement.SelectSingleNode(name);

                node.Attributes["value"].Value = value;
            }
示例#3
0
 private string this[ProfilePath path]
 {
     get
     {
         lock (_lock)
         {
             if (_newvalues.Contains(path))
             {
                 return((string)_newvalues[path]);
             }
             return((string)_values[path]);
         }
     }
     set
     {
         lock (_lock)
         {
             if (value != (string)_values[path])
             {
                 _newvalues[path] = value;
             }
             else
             {
                 _newvalues.Remove(path);
             }
         }
     }
 }
示例#4
0
        public void Flush()
        {
            lock (_lock)
            {
                if (_newvalues.Count == 0)
                {
                    return;
                }

                IDictionary result = new Hashtable(_values);
                IUpdate     batch  = CreateNewUpdate();

                foreach (DictionaryEntry newvalue in _newvalues)
                {
                    ProfilePath path  = (ProfilePath)newvalue.Key;
                    string      value = (string)newvalue.Value;

                    if (value == null)
                    {
                        if (_values.Contains(path))
                        {
                            batch.DeleteValue(path);
                            result.Remove(path);
                        }
                    }
                    else
                    {
                        if (_values.Contains(path))
                        {
                            batch.SaveValue(path, value);
                            result[path] = value;
                        }
                        else
                        {
                            batch.AddValue(path, value);
                            result.Add(path, value);
                        }
                    }
                }

                try
                {
                    batch.Execute();

                    _values = result;
                    _newvalues.Clear();

                    batch.AcceptChanges();
                }
                catch
#if DEBUG
                (Exception)
#endif
                {
                    batch.DiscardChanges();
                    throw;
                }
            }
        }
 public ProfilePathGridViewModel(ProfilePath profilePath) : this()
 {
     Id               = profilePath.Id;
     VerticalDepth    = profilePath.VerticalDepth;
     InclinationAngle = profilePath.InclinationAngle;
     AzimuthAngle     = profilePath.AzimuthAngle;
     Extension        = profilePath.Extension;
 }
示例#6
0
 private static string EncodedPath(ProfilePath path)
 {
     string[] paths = new string[path.Length];
     for (int i = 0; i < path.Length; i++)
     {
         paths[i] = XmlNormalizer.TagEncode(path[i]);
     }
     return(string.Join("/", paths));
 }
示例#7
0
 public IProfile this[string profilepath]
 {
     get
     {
         ProfilePath path = ProfilePath.RootPath.ResolvePath(profilepath);
         ProfileNode node = new ProfileNode(this, path);
         return(node.IsRoot ? (IProfile)node : (IProfile) new VirtualNode(node));
     }
 }
示例#8
0
        static public bool cmpLen(ProfilePath pp, double b = 0.6)
        {
            SketchEntity se1 = (SketchEntity)((ProfileEntity)pp[1]).SketchEntity;
            SketchEntity se2 = (SketchEntity)((ProfileEntity)pp[2]).SketchEntity;

            if (ParamLen(se1) == b || ParamLen(se2) == b)
            {
                return(true);
            }
            return(false);
        }
示例#9
0
 /// <summary>
 /// Entfernt die Datei zu einem Geräteprofil.
 /// </summary>
 public void Delete()
 {
     // Forward
     if (ProfilePath != null)
     {
         if (ProfilePath.Exists)
         {
             ProfilePath.Delete();
         }
     }
 }
示例#10
0
        public void GetNameWithExtensionTest(string name)
        {
            const string ext    = ProfilePath.PROFILE_FILE_EXTENSION;
            var          target = ProfilePath.GetNameWithExtension(name);

            Assert.EndsWith(ext, target);

            // checks if don't duplicate extension
            var occurrences = Regex.Matches(target, ext).Count;

            Assert.Equal(1, occurrences);
        }
示例#11
0
            public ProfilePath(ProfilePath parent, string child)
            {
                if (child == null || child.Length == 0)
                {
                    throw new ArgumentNullException("child");
                }
                string[] parentpath = parent._path;
                int      length     = parentpath.Length;

                _path = new string[length + 1];
                Array.Copy(parentpath, _path, length);
                _path[length] = child;
            }
示例#12
0
        public static async Task <bool> CleanProfile(string name)
        {
            var sett = await FreeJira.Infra.FreeJiraSettings.GetSettings();

            var file = ProfilePath.GetProfilePath(sett, name);

            if (file.Exists)
            {
                file.Delete();
                return(true);
            }

            return(false);
        }
		private void LoadXml(XmlElement element, ProfilePath path)
		{
			if ( element.HasAttribute("value") )
			{
				string value = element.GetAttribute("value");
				LoadValue(path, value);
			}

			foreach (XmlNode xmlnode in element.ChildNodes)
			{
				XmlElement child = xmlnode as XmlElement;
				if ( child != null )
					LoadXml(child, new ProfilePath(path, XmlNormalizer.TagDecode(child.LocalName)));
			}
		}
示例#14
0
        private void LoadXml(XmlElement element, ProfilePath path)
        {
            if (element.HasAttribute("value"))
            {
                string value = element.GetAttribute("value");
                LoadValue(path, value);
            }

            foreach (XmlNode xmlnode in element.ChildNodes)
            {
                XmlElement child = xmlnode as XmlElement;
                if (child != null)
                {
                    LoadXml(child, new ProfilePath(path, XmlNormalizer.TagDecode(child.LocalName)));
                }
            }
        }
示例#15
0
            public void DeleteValue(ProfilePath path)
            {
                string     name    = EncodedPath(path);
                XmlElement lastone = _document.DocumentElement.SelectSingleNode(name) as XmlElement;

                lastone.Attributes.RemoveNamedItem("value");
                XmlElement node = lastone.ParentNode as XmlElement;

                while (node != _document.DocumentElement)
                {
                    if (!node.HasAttribute("value"))
                    {
                        lastone = node;
                    }

                    node = node.ParentNode as XmlElement;
                }
                node.RemoveChild(lastone);
            }
示例#16
0
        /////////////////////////////////////////////////////////////
        // Use: Returns True if path argument contains same sketch
        //      entity than mainPath.
        /////////////////////////////////////////////////////////////
        private static bool HasMatchingEntity(ProfilePath path,
                                              ProfilePath mainPath)
        {
            foreach (ProfileEntity profileEnt1 in path)
            {
                foreach (ProfileEntity profileEnt2 in mainPath)
                {
                    if (profileEnt1.SketchEntity ==
                        profileEnt2.SketchEntity)
                    {
                        if (profileEnt1.SketchEntity is SketchLine)
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
示例#17
0
        public void GetProfilePathTest(string name)
        {
            const string folderName   = "data";
            var          settingsMock = new Mock <IFreeJiraSettings>();

            settingsMock.Setup(e => e.Folder)
            .Returns(new DirectoryInfo(folderName));

            var target     = ProfilePath.GetProfilePath(settingsMock.Object, name);
            var targetName = ProfilePath.GetNameWithExtension(name);

            Assert.NotNull(target);
            Assert.IsType <FileInfo>(target);
            Assert.Equal(ProfilePath.PROFILE_DEFAULT_FOLDER_NAME, target.Directory.Name);
            Assert.Equal(targetName, target.Name);

            var targetFolder = target.Directory.Parent.Name;

            Assert.Equal(folderName, targetFolder);
        }
示例#18
0
            public void AddValue(ProfilePath path, string value)
            {
                XmlNode rootnode = _document.DocumentElement;

                foreach (string name in path)
                {
                    XmlNode node = null;
                    string  n    = XmlNormalizer.TagEncode(name);
                    node = rootnode.SelectSingleNode(n);
                    if (node == null)
                    {
                        node = _document.CreateElement(n);
                        rootnode.AppendChild(node);
                    }
                    rootnode = node;
                }
                XmlAttribute attrib = _document.CreateAttribute("value");

                rootnode.Attributes.Append(attrib);
                attrib.Value = value;
            }
示例#19
0
 public override void Pulse()
 {
     if (File.Exists(ProfilePath) || ProfilePath.StartsWith("store://", true, CultureInfo.InvariantCulture))
     {
         Profile.Log("Loading Honorbuddy profile: {0} and {1}",
                     Profile.Settings.ProfileName, ProfilePath, !string.IsNullOrEmpty(Bot) ? "switching to bot " + Bot : "using current bot");
         Profile.Status = "Changing to Honorbuddy profile: " + Path.GetFileNameWithoutExtension(ProfilePath);
         Profile.TaskManager.HonorbuddyManager.Stop();
         var hbSettings = (HonorbuddySettings)Profile.Settings.HonorbuddySettings.ShadowCopy();
         hbSettings.HonorbuddyProfile = ProfilePath;
         if (!string.IsNullOrEmpty(Bot))
         {
             hbSettings.BotBase = Bot;
         }
         Profile.TaskManager.HonorbuddyManager.SetSettings(hbSettings);
         Profile.TaskManager.HonorbuddyManager.Start();
     }
     else
     {
         Profile.Err("Unable to find Honorbuddy profile {0}", ProfilePath);
     }
     IsDone = true;
 }
示例#20
0
 private void LoadValue(ProfilePath path, string value)
 {
     _values[path] = value;
 }
			protected ProfilePath(ProfilePath path, int start, int length)
			{
				_path = new string[length];
				Array.Copy(path._path, start, _path, 0, length);
			}
			internal ProfilePath(ProfilePath path)
			{
				_path = path._path;
			}
			public ProfilePath(ProfilePath parent, string child)
			{
				if ( child == null || child.Length == 0 )
					throw new ArgumentNullException("child");
				string[] parentpath = parent._path;
				int length = parentpath.Length;
				_path = new string[length + 1];
				Array.Copy(parentpath, _path, length);
				_path[length] = child;
			}
			public void DeleteValue(ProfilePath path)
			{
				string name = EncodedPath(path);
				XmlElement lastone = _document.DocumentElement.SelectSingleNode(name) as XmlElement;
				lastone.Attributes.RemoveNamedItem("value");
				XmlElement node = lastone.ParentNode as XmlElement;
				while (node != _document.DocumentElement)
				{
					if ( !node.HasAttribute("value") )
						lastone = node;

					node = node.ParentNode as XmlElement;
				}
				node.RemoveChild(lastone);
			}
			public void AddValue(ProfilePath path, string value)
			{
				XmlNode rootnode = _document.DocumentElement;
				foreach (string name in path)
				{
					XmlNode node = null;
					string n = XmlNormalizer.TagEncode(name);
					node = rootnode.SelectSingleNode(n);
					if ( node == null )
					{
						node = _document.CreateElement(n);
						rootnode.AppendChild(node);
					}
					rootnode = node;
				}
				XmlAttribute attrib = _document.CreateAttribute("value");
				rootnode.Attributes.Append(attrib);
				attrib.Value = value;
			}
示例#26
0
 protected ProfilePath(ProfilePath path, int start, int length)
 {
     _path = new string[length];
     Array.Copy(path._path, start, _path, 0, length);
 }
			public void SaveValue(ProfilePath path, string value)
			{
				string name = EncodedPath(path);
				XmlNode node = _document.DocumentElement.SelectSingleNode(name);
				node.Attributes["value"].Value = value;
			}
		private void LoadValue(ProfilePath path, string value)
		{
			_values[path] = value;
		}
		private string this[ProfilePath path]
		{
			get
			{
				lock (_lock)
				{
					if ( _newvalues.Contains(path) )
						return (string) _newvalues[path];
					return (string) _values[path];
				}
			}
			set
			{
				lock (_lock)
				{
					if ( value != (string) _values[path] )
						_newvalues[path] = value;
					else
						_newvalues.Remove(path);
				}
			}
		}
示例#30
0
        /// <summary>
        /// Gets the actual Movie Poster for this Movie
        /// </summary>
        /// <param name="size"></param>
        /// <returns></returns>
        public Image GetProfileImage(ProfileSize size)
        {
            Image x = null;

            if (ProfilePath != null)
            {
                String cachePath = PrivateData.GetAppPath() + @"\Cache\Images\Person\" + ProfilePath.Replace("/", "");

                if (File.Exists(cachePath))
                {
                    x = Image.FromFile(cachePath); // Use Image from Cache
                }
                else
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(cachePath));  // Insure Directory Exists
                    Uri uri = Uri(size);
                    var wc  = new WebClient();
                    x = Image.FromStream(wc.OpenRead(uri)); //Read from the Internet

                    x.Save(cachePath);                      //Save Image in Cache
                }
            }
            return(x);
        }
示例#31
0
 internal ProfilePath(ProfilePath path)
 {
     _path = path._path;
 }
			public ProfileNode(XmlProfileStore store, ProfilePath path)
				: base(path)
			{
				_store = store;
			}
			private static string EncodedPath(ProfilePath path)
			{
				string[] paths = new string[path.Length];
				for (int i = 0; i < path.Length; i++)
					paths[i] = XmlNormalizer.TagEncode(path[i]);
				return string.Join("/", paths);
			}
示例#34
0
 public ProfileNode(XmlProfileStore store, ProfilePath path)
     : base(path)
 {
     _store = store;
 }