Esempio n. 1
0
        public static string ToFieldName(this string columnName, string prefix, CodeStyle style = CodeStyle.Original)
        {
            string fieldName = ident.Identifier(columnName, prefix);

            char ch = fieldName[0];

            switch (style)
            {
            case CodeStyle.Pascal:
                if (char.IsLower(ch))
                {
                    return(char.ToUpper(ch) + fieldName.Substring(1));
                }
                break;

            case CodeStyle.Camel:
                if (char.IsUpper(ch))
                {
                    return(char.ToLower(ch) + fieldName.Substring(1));
                }
                break;
            }

            return(fieldName);
        }
Esempio n. 2
0
        public static void WhenAdjacentWithEmptyLine()
        {
            var syntaxTree  = CSharpSyntaxTree.ParseText(@"
namespace N
{
    public class C
    {
        public C()
        {
        }

        private int f1;

        public int P1
        {
            get => this.f1;
            set => this.f1 = value;
        }
    }
}");
            var compilation = CSharpCompilation.Create("test", new[] { syntaxTree });

            Assert.AreEqual(CodeStyleResult.Yes, CodeStyle.BackingFieldsAdjacent(compilation.GetSemanticModel(syntaxTree), out var newLineBetween));
            Assert.AreEqual(true, newLineBetween);
        }
Esempio n. 3
0
        public static void ChecksContainingClassFirst()
        {
            var c1 = CSharpSyntaxTree.ParseText(@"
namespace N
{
    class C1
    {
        private int _f;
    }
}");

            var c2            = CSharpSyntaxTree.ParseText(@"
namespace N
{
    class C1
    {
        private int value;
    }
}");
            var compilation   = CSharpCompilation.Create("test", new[] { c1, c2 }, MetadataReferences.FromAttributes());
            var semanticModel = compilation.GetSemanticModel(compilation.SyntaxTrees[0]);

            Assert.AreEqual(CodeStyleResult.Yes, CodeStyle.UnderscoreFields(semanticModel));

            semanticModel = compilation.GetSemanticModel(compilation.SyntaxTrees[1]);
            Assert.AreEqual(CodeStyleResult.No, CodeStyle.UnderscoreFields(semanticModel));
        }
Esempio n. 4
0
        public static void WhenStyleCop()
        {
            var syntaxTree    = CSharpSyntaxTree.ParseText(@"
namespace N
{
    public class C
    {
        private int f1;

        public C()
        {
        }

        public int P1
        {
            get => this.f1;
            set => this.f1 = value;
        }
    }
}");
            var compilation   = CSharpCompilation.Create("test", new[] { syntaxTree });
            var semanticModel = compilation.GetSemanticModel(syntaxTree);

            Assert.AreEqual(CodeStyleResult.No, CodeStyle.BackingFieldsAdjacent(semanticModel, out _));
        }
Esempio n. 5
0
        public static void FindsInOtherDocument()
        {
            var syntaxTree1 = CSharpSyntaxTree.ParseText(@"
namespace N
{
    public class C
    {
    }
}");

            var syntaxTree2 = CSharpSyntaxTree.ParseText(@"
namespace N
{
    public class C
    {
        private int f1;

        public C()
        {
        }

        public int P1
        {
            get => this.f1;
            set => this.f1 = value;
        }
    }
}");
            var compilation = CSharpCompilation.Create("test", new[] { syntaxTree1, syntaxTree2 });

            Assert.AreEqual(CodeStyleResult.No, CodeStyle.BackingFieldsAdjacent(compilation.GetSemanticModel(syntaxTree1), out _));
            Assert.AreEqual(CodeStyleResult.No, CodeStyle.BackingFieldsAdjacent(compilation.GetSemanticModel(syntaxTree2), out _));
        }
Esempio n. 6
0
        public static void FindsAdjacentInCompilation()
        {
            var syntaxTree1 = CSharpSyntaxTree.ParseText(@"
namespace N
{
    public class C
    {
    }
}");

            var syntaxTree2   = CSharpSyntaxTree.ParseText(@"
namespace N
{
    public class C
    {
        public C()
        {
        }

        private int f1;

        public int P1
        {
            get => this.f1;
            set => this.f1 = value;
        }
    }
}");
            var compilation   = CSharpCompilation.Create("test", new[] { syntaxTree1, syntaxTree2 });
            var semanticModel = compilation.GetSemanticModel(syntaxTree1);

            Assert.AreEqual(CodeStyleResult.Yes, CodeStyle.BackingFieldsAdjacent(semanticModel, out var newLine));
            Assert.AreEqual(true, newLine);
        }
Esempio n. 7
0
        public string Register(
            CodeStyle Style,
            string redirectUri)
        {
            Debug.Assert(null != redirectUri);

            string returnHTML = "<div> </div>";
            if (CodeStyle.HTML5 == Style)
            {
                // note ---- this only exists in XFBML right now. Cheat for now and return XFBML until FB fixes this
                returnHTML = "<fb:registration " +
                                            "redirect-uri=\"" + redirectUri + "\" " +
                                            "fields=\"" + getFields() + "\" " +
                                            "/>";
            }
            else if (CodeStyle.IFRAME == Style)
            {
                returnHTML = "<iframe " + getSrcString(fbRegistrationUri + "?" +
                                                            getClientId() + "&amp;" +
                                                            getRedirectUri(redirectUri) + "&amp;" +
                                                            "fields=" + getFields())
                                             + getRegistrationOptions() + "> </iframe>";
            }
            return returnHTML;
        }
Esempio n. 8
0
        public static void FiguresOutFromOtherTree(string declaration, CodeStyleResult expected)
        {
            var c1 = CSharpSyntaxTree.ParseText(@"
namespace N
{
    class C1
    {
        private int _f;
    }
}".AssertReplace("private int _f", declaration));

            var c2          = CSharpSyntaxTree.ParseText(@"
namespace N
{
    class C2
    {
    }
}");
            var compilation = CSharpCompilation.Create("test", new[] { c1, c2 }, MetadataReferences.FromAttributes());

            Assert.AreEqual(2, compilation.SyntaxTrees.Length);
            foreach (var tree in compilation.SyntaxTrees)
            {
                var semanticModel = compilation.GetSemanticModel(tree);
                Assert.AreEqual(expected, CodeStyle.UnderscoreFields(semanticModel));
            }
        }
Esempio n. 9
0
        public static void FiguresOutFromOtherDocument(string declaration, CodeStyleResult expected)
        {
            var sln = CodeFactory.CreateSolution(new[]
            {
                @"
namespace N
{
    class C1
    {
        private int _f;
    }
}".AssertReplace("private int _f", declaration),
                @"
namespace N
{
    class C2
    {
    }
}",
            });

            foreach (var document in sln.Projects.Single().Documents)
            {
                var editor = Microsoft.CodeAnalysis.Editing.DocumentEditor.CreateAsync(document).Result;
                Assert.AreEqual(expected, CodeStyle.UnderscoreFields(editor));
            }
        }
Esempio n. 10
0
        public static void TwoProperties()
        {
            var syntaxTree  = CSharpSyntaxTree.ParseText(@"
namespace N
{
    public class C
    {
        private int f1;

        public int P1
        {
            get => this.f1;
            set => this.f1 = value;
        }

        private int f2;

        public int P2
        {
            get => this.f2;
            set => this.f2 = value;
        }
    }
}");
            var compilation = CSharpCompilation.Create("test", new[] { syntaxTree });

            Assert.AreEqual(CodeStyleResult.Yes, CodeStyle.BackingFieldsAdjacent(compilation.GetSemanticModel(syntaxTree), out _));
        }
Esempio n. 11
0
        /// <summary>
        /// Creates a Like (and Send) button ---- most common control
        /// </summary>
        /// <param name="Style"></param>
        /// <param name="Ref"></param>
        /// <param name="HRef"></param>
        /// <param name="AddSendButton"></param>
        /// <param name="ShowFaces"></param>
        /// <param name="PluginWidth"></param>
        /// <returns></returns>
        public string Like(
            CodeStyle   Style,
            string      Ref,    // always pass a unique Ref for all FB plugins --- any clickbacks have this passed as a fb_ref parameter
            string      HRef, 
            bool        AddSendButton = false,
            bool        ShowFaces=true, 
            int         PluginWidth=200)
        {
            string returnHTML = "<div> </div>";
            if (CodeStyle.HTML5 == Style)
            {
                returnHTML = "<div class=\"fb-like\" " +
                                            "data-show-faces=\"" + ((true == ShowFaces) ? "true" : "false") + "\" " +
                                            "data-send=\"" + ((true == AddSendButton) ? "true" : "false") + "\" " +
                                            "data-width=\"" + PluginWidth + "\" " +
                                            ((null != HRef)? ("data-href=\"" + HRef + "\"") : "") +
                                            ((null != Ref)? ("data-ref=\"" + Ref + "\"") : "") +
                                            "></div>";
            }
            else if (CodeStyle.IFRAME == Style)
            {
                // TODO: for now, require HRef and ignore Ref for the IFrame implementation....
                Debug.Assert(null != HRef);
                Debug.Assert((false == AddSendButton), "Send button not supported with IFRAME");

                returnHTML = "<iframe src=\"http://www.facebook.com/plugins/like.php?href=" + HRef + "\"" +
                                "scrolling=\"no\" frameborder=\"0\"" +
                                "style=\"border:none; width:" + PluginWidth + "px; height:80px\"></iframe>";
            }
            return returnHTML;
        }
Esempio n. 12
0
        public static async Task FiguresOutFromOtherDocument(string declaration, CodeStyleResult expected)
        {
            var sln = CodeFactory.CreateSolution(
                new[]
            {
                @"
namespace N
{
    class C1
    {
        private int _f;
    }
}".AssertReplace("private int _f", declaration),
                @"
namespace N
{
    class C2
    {
    }
}",
            });

            foreach (var document in sln.Projects.Single().Documents)
            {
                Assert.AreEqual(expected, await CodeStyle.UnderscoreFieldsAsync(document, CancellationToken.None).ConfigureAwait(false));
            }
        }
Esempio n. 13
0
 /// <summary>
 /// Generates a control to allow the user to like a specific Facebook page (without having to go there).
 /// This works for Facebook "pages" only (i.e. owned by commercial businesses) not consumer facebook pages
 /// </summary>
 /// <param name="Style"></param>
 /// <param name="HRef"></param>
 /// <param name="ShowFaces"></param>
 /// <param name="ShowStream"></param>
 /// <param name="ShowHeader"></param>
 /// <param name="PluginWidth"></param>
 /// <returns></returns>
 public string LikeBox(
     CodeStyle Style,
     string HRef,
     bool ShowFaces = true,
     bool ShowStream = true,
     bool ShowHeader = false,
     int PluginWidth = 300)
 {
     string returnHTML = "<div> </div>";
     if (CodeStyle.HTML5 == Style)
     {
         returnHTML = "<div class=\"fb-like-box\" " +
                                     "data-show-faces=\"" + ((true == ShowFaces) ? "true" : "false") + "\" " +
                                     "data-stream=\"" + ((true == ShowStream) ? "true" : "false") + "\" " +
                                     "data-header=\"" + ((true == ShowHeader) ? "true" : "false") + "\" " +
                                     "data-width=\"" + PluginWidth + "\" " +
                                     ((null != HRef) ? ("data-href=\"" + HRef + "\"") : "") +
                                     "></div>";
     }
     else if (CodeStyle.IFRAME == Style)
     {
         Debug.Assert(false, "IFRAME is supported for LikeBox, but not yet implemented here");
     }
     return returnHTML;
 }
Esempio n. 14
0
        public static void TwoProperties()
        {
            var editor = CreateDocumentEditor(@"
namespace N
{
    public class C
    {
        private int f1;

        public int P1
        {
            get => this.f1;
            set => this.f1 = value;
        }

        private int f2;

        public int P2
        {
            get => this.f2;
            set => this.f2 = value;
        }
    }
}");

            Assert.AreEqual(CodeStyleResult.Yes, CodeStyle.BackingFieldsAdjacent(editor, out var newLineBetween));
            Assert.AreEqual(true, newLineBetween);
        }
Esempio n. 15
0
        public void FiguresOutFromOtherClass()
        {
            var fooCode = CSharpSyntaxTree.ParseText(@"
namespace RoslynSandbox
{
    class Foo
    {
        private int _value;

        public int Bar()  => _value = 1;
    }
}");

            var barCode     = CSharpSyntaxTree.ParseText(@"
namespace RoslynSandbox
{
    class Bar
    {
    }
}");
            var compilation = CSharpCompilation.Create("test", new[] { fooCode, barCode }, MetadataReferences.FromAttributes());

            Assert.AreEqual(2, compilation.SyntaxTrees.Length);
            foreach (var tree in compilation.SyntaxTrees)
            {
                var semanticModel = compilation.GetSemanticModel(tree);
                Assert.AreEqual(true, CodeStyle.UnderscoreFields(semanticModel));
            }
        }
Esempio n. 16
0
		public ClassBuilder(string TypePrefix,CodeStyle Style,string TypePostfix,string Ancestor)
		{
			this.TypePrefix = TypePrefix;
			this.Style = Style;
			this.TypePostfix = TypePostfix;
			this.Ancestor = Ancestor;
			sb = new StringBuilder();
		}
Esempio n. 17
0
		public ClassBuilder()
		{
			 Style = CodeStyle.cnet;
			 TypePrefix = null;
			 TypePostfix = null;
			 Ancestor = null;
			 sb = new StringBuilder();
 		}
Esempio n. 18
0
 public ClassBuilder()
 {
     Style       = CodeStyle.cnet;
     TypePrefix  = null;
     TypePostfix = null;
     Ancestor    = null;
     sb          = new StringBuilder();
 }
Esempio n. 19
0
 public ClassBuilder(string TypePrefix, CodeStyle Style, string TypePostfix, string Ancestor)
 {
     this.TypePrefix  = TypePrefix;
     this.Style       = Style;
     this.TypePostfix = TypePostfix;
     this.Ancestor    = Ancestor;
     sb = new StringBuilder();
 }
Esempio n. 20
0
 /// <summary>
 ///  生成验证图片
 /// </summary>
 /// <param name="count">验证码长度4-16</param>
 /// <param name="width">图片宽度16-360</param>
 /// <param name="height">图片高度16-320</param>
 /// <param name="style">验证码样式</param>
 /// <param name="code">返回的验证码</param>
 /// <returns></returns>
 public static byte[] Create(int count, int width, int height, CodeStyle style, out string code)
 {
     CODELEN      = count;
     IMAGE_WIDTH  = width;
     IMAGE_HEIGHT = height;
     codestyle    = style;
     code         = string.Empty;
     return(Create(out code));
 }
Esempio n. 21
0
        public static void WhenUnknown()
        {
            var editor = CreateDocumentEditor(@"
namespace N
{
}");

            Assert.AreEqual(CodeStyleResult.NotFound, CodeStyle.UsingDirectivesInsideNamespace(editor));
        }
Esempio n. 22
0
        public static void UsingDirectiveInsideNamespace()
        {
            var editor = CreateDocumentEditor(@"
namespace N
{
    using System;
}");

            Assert.AreEqual(CodeStyleResult.Yes, CodeStyle.UsingDirectivesInsideNamespace(editor));
        }
Esempio n. 23
0
        public static void UsingDirectiveInsideAndOutsideNamespace()
        {
            var editor = CreateDocumentEditor(@"
using System;

namespace N
{
    using System.Collections;
}");

            Assert.AreEqual(CodeStyleResult.Mixed, CodeStyle.UsingDirectivesInsideNamespace(editor));
        }
Esempio n. 24
0
        public static void WhenUnknown()
        {
            var editor = CreateDocumentEditor(@"
namespace N
{
    public class C
    {
    }
}");

            Assert.AreEqual(CodeStyleResult.NotFound, CodeStyle.BackingFieldsAdjacent(editor, out _));
        }
Esempio n. 25
0
        public static void WhenUnknown()
        {
            var syntaxTree = CSharpSyntaxTree.ParseText(@"
namespace N
{
}");

            var compilation   = CSharpCompilation.Create("test", new[] { syntaxTree }, Settings.Default.MetadataReferences);
            var semanticModel = compilation.GetSemanticModel(syntaxTree);

            Assert.AreEqual(CodeStyleResult.NotFound, CodeStyle.UsingDirectivesInsideNamespace(semanticModel));
        }
Esempio n. 26
0
        public static void UsingDirectiveInsideNamespace()
        {
            var syntaxTree = CSharpSyntaxTree.ParseText(@"
namespace N
{
    using System;
}");

            var compilation   = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.FromAttributes());
            var semanticModel = compilation.GetSemanticModel(syntaxTree);

            Assert.AreEqual(CodeStyleResult.Yes, CodeStyle.UsingDirectivesInsideNamespace(semanticModel));
        }
Esempio n. 27
0
        public static void WhenUnknown()
        {
            var syntaxTree    = CSharpSyntaxTree.ParseText(@"
namespace N
{
    public class C
    {
    }
}");
            var compilation   = CSharpCompilation.Create("test", new[] { syntaxTree });
            var semanticModel = compilation.GetSemanticModel(syntaxTree);

            Assert.AreEqual(CodeStyleResult.NotFound, CodeStyle.BackingFieldsAdjacent(semanticModel, out _));
        }
Esempio n. 28
0
        public static void UsingDirectiveInsideAndOutsideNamespace()
        {
            var syntaxTree = CSharpSyntaxTree.ParseText(@"
using System;

namespace N
{
    using System.Collections;
}");

            var compilation   = CSharpCompilation.Create("test", new[] { syntaxTree }, Settings.Default.MetadataReferences);
            var semanticModel = compilation.GetSemanticModel(syntaxTree);

            Assert.AreEqual(CodeStyleResult.Mixed, CodeStyle.UsingDirectivesInsideNamespace(semanticModel));
        }
Esempio n. 29
0
        public static void WhenField(string declaration, CodeStyleResult expected)
        {
            var syntaxTree = CSharpSyntaxTree.ParseText(@"
namespace N
{
    class C
    {
        private int _f;
    }
}".AssertReplace("private int _f", declaration));

            var compilation   = CSharpCompilation.Create("test", new[] { syntaxTree });
            var semanticModel = compilation.GetSemanticModel(syntaxTree);

            Assert.AreEqual(expected, CodeStyle.UnderscoreFields(semanticModel));
        }
Esempio n. 30
0
        public void WhenFieldIsNotNamedWithUnderscore()
        {
            var syntaxTree = CSharpSyntaxTree.ParseText(@"
namespace RoslynSandbox
{
    class Foo
    {
        int value;
        public int Bar()  => value = 1;
    }
}");

            var compilation   = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.FromAttributes());
            var semanticModel = compilation.GetSemanticModel(syntaxTree);

            Assert.AreEqual(false, CodeStyle.UnderscoreFields(semanticModel));
        }
Esempio n. 31
0
        public void WhenUsingThis()
        {
            var syntaxTree = CSharpSyntaxTree.ParseText(@"
namespace RoslynSandbox
{
    class Foo
    {
        public int Value { get; private set; }

        public int Bar()  => this.value = 1;
    }
}");

            var compilation   = CSharpCompilation.Create("test", new[] { syntaxTree }, MetadataReferences.FromAttributes());
            var semanticModel = compilation.GetSemanticModel(syntaxTree);

            Assert.AreEqual(false, CodeStyle.UnderscoreFields(semanticModel));
        }
Esempio n. 32
0
        public static void TwoExpressionBodyProperties()
        {
            var editor = CreateDocumentEditor(@"
namespace N
{
    public class C
    {
        private int f1;
        public int P1 => this.f1;

        private int f2;
        public int P2 => this.f2;
    }
}");

            Assert.AreEqual(CodeStyleResult.Yes, CodeStyle.BackingFieldsAdjacent(editor, out var newLineBetween));
            Assert.AreEqual(false, newLineBetween);
        }
Esempio n. 33
0
        public static void Repro()
        {
            var editor = CreateDocumentEditor(@"
namespace Vanguard_MVVM.ViewModels
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;

    public sealed class MainWindowViewModel : INotifyPropertyChanged
    {
        IChildDataContext _childDataContext;
        readonly string _title;
        MainWindowViewModel()
        {
            _title = ""MVVM Attempt"";
        }

        public IChildDataContext ChildDataContext
        {
            get { return _childDataContext; }

            private set
            {
                if (Equals(value, _childDataContext)) return;
                ↓_childDataContext = value;
                NotifyPropertyChanged(nameof(ChildDataContext));
            }
        }

        public static MainWindowViewModel Instance { get; } = new MainWindowViewModel();

        public string Title => ChildDataContext?.Title == null ? _title : string.Concat(_title, "" - "", ChildDataContext?.Title);


        public event PropertyChangedEventHandler PropertyChanged;

        void NotifyPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));

    }
}");

            Assert.AreEqual(CodeStyleResult.Yes, CodeStyle.UnderscoreFields(editor));
        }
Esempio n. 34
0
        public static void TwoExpressionBodyProperties()
        {
            var syntaxTree  = CSharpSyntaxTree.ParseText(@"
namespace N
{
    public class C
    {
        private int f1;
        public int P1 => this.f1;

        private int f2;
        public int P2 => this.f2;
    }
}");
            var compilation = CSharpCompilation.Create("test", new[] { syntaxTree });

            Assert.AreEqual(CodeStyleResult.Yes, CodeStyle.BackingFieldsAdjacent(compilation.GetSemanticModel(syntaxTree), out var newLineBetween));
            Assert.AreEqual(false, newLineBetween);
        }
Esempio n. 35
0
        public static void WhenUnknownOneProperty()
        {
            var editor = CreateDocumentEditor(@"
namespace N
{
    public class C
    {
        private int f1;

        public int P1
        {
            get => this.f1;
            set => this.f1 = value;
        }
    }
}");

            Assert.AreEqual(CodeStyleResult.NotFound, CodeStyle.BackingFieldsAdjacent(editor, out _));
        }
Esempio n. 36
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="Style"></param>
        /// <param name="PluginWidth"></param>
        /// <returns></returns>
        public string AppFacepile(
            CodeStyle Style,
            int PluginWidth = 200)
        {
            string returnHTML = "<div> </div>";
            if (CodeStyle.HTML5 == Style)
            {
                //pass in the app id when calling FB.init
                returnHTML = "<div class=\"fb-facepile\" " +
                                            "data-width=\"" + PluginWidth + "\" " +
                                            "></div>";
            }
            else if (CodeStyle.IFRAME == Style)
            {
                returnHTML = "<iframe src=\"http://www.facebook.com/plugins/facepile.php?app_id=" + this.FBAppId + "&amp;" +
                                "width=" + PluginWidth + "\"" +
                                "scrolling=\"no\" frameborder=\"0\"" +
                                "style=\"border:none; width:" + PluginWidth + "px; height:80px\"></iframe>";

            }
            return returnHTML;
        }
Esempio n. 37
0
 public string Comments(
     CodeStyle   Style,
     string      HRef, 
     int         NumComments=10,
     int         PluginWidth=300)
 {
     string returnHTML = "<div> </div>";
     Debug.Assert(null != HRef);
     if (CodeStyle.HTML5 == Style)
     {
         returnHTML = "<div class=\"fb-comments\" " +
                                     "data-width=\"" + PluginWidth + "\" " +
                                     "data-num-posts=\"" + NumComments + "\" " +
                                     "data-href=\"" + HRef + "\"" +
                                     "\"></div>";
     }
     else if (CodeStyle.IFRAME == Style)
     {
         Debug.Assert(false, "IFRAME not supported for Comments box");
     }
     return returnHTML;
 }
Esempio n. 38
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="Style"></param>
        /// <param name="HRef"></param>
        /// <param name="PluginWidth"></param>
        /// <returns></returns>
        public string LikeFacepile(
            CodeStyle Style,
            string HRef,
            int PluginWidth = 200)
        {
            string returnHTML = "<div> </div>";
            if (CodeStyle.HTML5 == Style)
            {
                returnHTML = "<div class=\"fb-facepile\" " +
                                            "data-width=\"" + PluginWidth + "\" " +
                                            ((null != HRef) ? ("data-href=\"" + HRef + "\"") : "") +
                                            "></div>";
            }
            else if (CodeStyle.IFRAME == Style)
            {
                returnHTML = "<iframe src=\"http://www.facebook.com/plugins/facepile.php?href=" + HRef + "&amp;" +
                                "width=" + PluginWidth + "\"" +
                                "scrolling=\"no\" frameborder=\"0\"" +
                                "style=\"border:none; width:" + PluginWidth + "px; height:80px\"></iframe>";

            }
            return returnHTML;
        }
Esempio n. 39
0
 public string ActivityFeed(
     CodeStyle   Style,                                 
     string      Ref,    // always pass a unique Ref for all FB plugins --- any clickbacks have this passed as a fb_ref parameter
     string      Sites,  // comma-separated list of domains to show activity for
     bool        ShowHeader = false, 
     bool        ShowRecos = true,
     int         PluginWidth = 300,
     int         PluginHeight = 300)
 {
     string returnHTML = "<div> </div>";
     Debug.Assert(null != Sites);
     Debug.Assert(null != Ref);
     if (CodeStyle.HTML5 == Style)
     {
         returnHTML = "<div class=\"fb-activity\" " +
                                     "data-site=\"" + Sites + "\"" +
                                     "data-header=\"" + ((true == ShowHeader) ? "true" : "false") + "\" " +
                                     "data-recommendations=\"" + ((true == ShowRecos) ? "true" : "false") + "\" " +
                                     "data-width=\"" + PluginWidth + "\" " +
                                     "data-height=\"" + PluginHeight + "\" " +
                                     "data-ref=\"" + Ref + "\"" +
                                     "\"></div>";
     }
     else if (CodeStyle.IFRAME == Style)
     {
         returnHTML = "<iframe src=\"http://www.facebook.com/plugins/activity.php?" +
                          "site=" + Sites + "&amp;" +
                          "width=" + PluginWidth + "&amp;" +
                          "height=" + PluginHeight + "&amp;" +
                          "header=" + ((true == ShowHeader)?"true":"false") + "&amp;" +
                          "recommendations=" + ((true == ShowRecos)?"true":"false") + "\"" +
                         "scrolling=\"no\" frameborder=\"0\"" +
                         "style=\"border:none; width:" + PluginWidth + "px; height:" + PluginHeight + "px;\">" +
                         "</iframe>";
     }
     return returnHTML;
 }
Esempio n. 40
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="Style"></param>
 /// <param name="Permissions"></param>
 /// <param name="ShowFaces"></param>
 /// <param name="DataWidth"></param>
 /// <param name="MaxDataRows"></param>
 /// <returns></returns>
 public string Login(
     CodeStyle       Style,
     string          ButtonText,
     FBPermissions   Permissions = null, 
     bool            ShowFaces=false, 
     int             DataWidth=200, 
     int             MaxDataRows=1)
 {
     string returnHTML = "<div> </div>";
     if (CodeStyle.HTML5 == Style)
     {
         returnHTML = "<div class=\"fb-login-button\" " +
                                     "data-show-faces=\"" + ((true == ShowFaces) ? "true" : "false") + "\" " +
                                     "data-width=\"" + DataWidth + "\" " +
                                     "data-max-rows=\"" + MaxDataRows + "\" " +
                                     ((null != Permissions) ? ("data-perms=\"" + Permissions.CSV + "\"") : "") +
                                     ">" + ButtonText + "</div>";
     }
     else
     {
         Debug.Assert(false, "Only HTML5 supported for login button");
     }
     return returnHTML;
 }
Esempio n. 41
0
        public void Load()
        {
            Xml profile = new Xml(GetSettingsPath());

            string style_xml = profile.GetValue(SECTION, "Style", "MS");

            CodeStyle styleGet = (CodeStyle)Enum.Parse(typeof(CodeStyle), style_xml);
            style = styleGet;
            identUseTab = profile.GetValue(SECTION, "IdentUseTab", true);
            identNumber = profile.GetValue(SECTION, "IdentNumber", 4);
            addSpaceAfterCtrlWord = profile.GetValue(SECTION, "AddSpaceAfterCtrlWord", false);
            autoCompleteBracket = profile.GetValue(SECTION, "AutoCompleteBracket", false);
            try
            {
                removeBlankLine = (BlankLineOption)profile.GetValue(BLACKLINE, "RemoveBlankLine", 1);
            }
            catch (System.Exception e)
            {

            }
            keepBlankLineCount = profile.GetValue(BLACKLINE, "KeepBlankLineCount", 2);
            MaxBlankLine = profile.GetValue(BLACKLINE, "MaxBlankLine", 2);
        }
 protected IDictionary<OptionKey, object> Option(PerLanguageOption<CodeStyle.CodeStyleOption<bool>> option, bool value, CodeStyle.NotificationOption notification)
 {
     return OptionsSet(Tuple.Create(option, value, notification));
 }
Esempio n. 43
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="Style"></param>
 /// <param name="RegisterCallbackUri"></param>
 /// <returns></returns>
 public string RegisterOrLogin(
     CodeStyle       Style,
     string          RegisterCallbackUri,
     FBPermissions   Permissions = null)
 {
     string returnHTML = "<div> </div>";
     Debug.Assert(null != RegisterCallbackUri);
     if (CodeStyle.HTML5 == Style)
     {
         // note ---- this only exists in XFBML right now. Cheat for now and return XFBML until FB fixes this
         returnHTML = "<div><fb:login-button " +
                                     "registration-url=\"" + RegisterCallbackUri + "\" " +
                                     ((null != Permissions) ? ("perms=\"" + Permissions.CSV + "\"") : "") +
                                     "/></div>";
     }
     else
     {
         Debug.Assert(false, "Only HTML5 supported for register/login button");
     }
     return returnHTML;
 }