コード例 #1
0
        public bool HasFeature(string featureName)
        {
            AssertStorage();

            if (!storage.ContainsKey(featureName))
            {
                return(false);
            }

            FeatureNode fn = storage [featureName];

            if (fn == null)
            {
                return(false);
            }

            List <FeatureBlock> blocks = fn.Blocks;

            if (blocks == null || blocks.Count == 0)
            {
                return(false);
            }

            return(true);
        }
コード例 #2
0
        public void StoreConfiguration()
        {
            AssertStorage();

            List <FeatureBlock>  blocksClone = new List <FeatureBlock> (blocks.Count);
            List <FeatureAction> abc         = new List <FeatureAction> (actionsBefore.Count);
            List <FeatureAction> aac         = new List <FeatureAction> (actionsAfter.Count);

            blocksClone.AddRange(blocks);
            abc.AddRange(actionsBefore);
            aac.AddRange(actionsAfter);
            FeatureNode fn = new FeatureNode(blocksClone, description.ToString(), abc, aac);

            if (storage.ContainsKey(name))
            {
                storage [name] = fn; // allow for silent override
            }
            else
            {
                storage.Add(name, fn);
            }

            blocks.Clear();
            actionsBefore.Clear();
            actionsAfter.Clear();
            description.Length = 0;
        }
コード例 #3
0
        string FormatFeatureDescription(string name, FeatureNode fn)
        {
            if (fn == null)
            {
                return(null);
            }

            List <FeatureBlock> lfb = fn.Blocks;

            if (lfb == null || lfb.Count == 0)
            {
                return(null);
            }

            StringBuilder ret = new StringBuilder();

            ret.AppendFormat("{0} (Target: {1})", name, lfb [0].Target);

            List <FeatureAction> al = fn.ActionsBefore;

            if (al != null && al.Count > 0)
            {
                ret.AppendFormat("; {0} actions before", al.Count);
            }

            al = fn.ActionsAfter;
            if (al != null && al.Count > 0)
            {
                ret.AppendFormat("; {0} actions after", al.Count);
            }

            ret.Append("\n");

            string desc = fn.Description;

            if (String.IsNullOrEmpty(desc))
            {
                return(ret.ToString());
            }

            string indent       = "     ";
            int    maxLineWidth = Console.WindowWidth - indent.Length;

            string[] dlines = desc.Trim().Split('\n');
            string   line;

            foreach (string l in dlines)
            {
                if (l.Length == 0)
                {
                    ret.Append("\n");
                    continue;
                }

                line = l.Trim();
                if (line.Length > maxLineWidth)
                {
                    ret.AppendFormat("{0}\n", Helpers.BreakLongLine(line, indent, maxLineWidth));
                }
                else
                {
                    ret.AppendFormat("{0}{1}\n", indent, line);
                }
            }

            ret.Append("\n");
            return(ret.ToString());
        }
コード例 #4
0
ファイル: FeatureNodeHandler.cs プロジェクト: nobled/mono
		public void StoreConfiguration ()
		{
			AssertStorage ();

			List <FeatureBlock> blocksClone = new List <FeatureBlock> (blocks.Count);
			List <FeatureAction> abc = new List <FeatureAction> (actionsBefore.Count);
			List <FeatureAction> aac = new List <FeatureAction> (actionsAfter.Count);
			
			blocksClone.AddRange (blocks);
			abc.AddRange (actionsBefore);
			aac.AddRange (actionsAfter);
			FeatureNode fn = new FeatureNode (blocksClone, description.ToString (), abc, aac);
				
			if (storage.ContainsKey (name))
				storage [name] = fn; // allow for silent override
			else
				storage.Add (name, fn);
				
			blocks.Clear ();
			actionsBefore.Clear ();
			actionsAfter.Clear ();
			description.Length = 0;
		}
コード例 #5
0
ファイル: FeatureNodeHandler.cs プロジェクト: nobled/mono
		string FormatFeatureDescription (string name, FeatureNode fn)
		{
			if (fn == null)
				return null;
			
			List <FeatureBlock> lfb = fn.Blocks;
			if (lfb == null || lfb.Count == 0)
				return null;

			StringBuilder ret = new StringBuilder ();
			ret.AppendFormat ("{0} (Target: {1})", name, lfb [0].Target);

			List <FeatureAction> al = fn.ActionsBefore;
			if (al != null && al.Count > 0)
				ret.AppendFormat ("; {0} actions before", al.Count);

			al = fn.ActionsAfter;
			if (al != null && al.Count > 0)
				ret.AppendFormat ("; {0} actions after", al.Count);

			ret.Append ("\n");
			
			string desc = fn.Description;
			if (String.IsNullOrEmpty (desc))
				return ret.ToString ();
			
			string indent = "     ";
			int maxLineWidth = Console.WindowWidth - indent.Length;
			string[] dlines = desc.Trim ().Split ('\n');
			string line;
			
			foreach (string l in dlines) {
				if (l.Length == 0) {
					ret.Append ("\n");
					continue;
				}
				
				line = l.Trim ();
				if (line.Length > maxLineWidth)
					ret.AppendFormat ("{0}\n", Helpers.BreakLongLine (line, indent, maxLineWidth));
				else
					ret.AppendFormat ("{0}{1}\n", indent, line);
			}

			ret.Append ("\n");
			return ret.ToString ();
		}