Search Results

Search found 5101 results on 205 pages for 'expression trees'.

Page 57/205 | < Previous Page | 53 54 55 56 57 58 59 60 61 62 63 64  | Next Page >

  • How do I tell if an action is a lambda expression?

    - by Keith
    I am using the EventAgregator pattern to subscribe and publish events. If a user subscribes to the event using a lambda expression, they must use a strong reference, not a weak reference, otherwise the expression can be garbage collected before the publish will execute. I wanted to add a simple check in the DelegateReference so that if a programmer passes in a lambda expression and is using a weak reference, that I throw an argument exception. This is to help "police" the code. Example: eventAggregator.GetEvent<RuleScheduler.JobExecutedEvent>().Subscribe ( e => resetEvent.Set(), ThreadOption.PublisherThread, false, // filter event, only interested in the job that this object started e => e.Value1.JobDetail.Name == jobName ); public DelegateReference(Delegate @delegate, bool keepReferenceAlive) { if (@delegate == null) throw new ArgumentNullException("delegate"); if (keepReferenceAlive) { this._delegate = @delegate; } else { //TODO: throw exception if target is a lambda expression _weakReference = new WeakReference(@delegate.Target); _method = @delegate.Method; _delegateType = @delegate.GetType(); } } any ideas? I thought I could check for @delegate.Method.IsStatic but I don't believe that works... (is every lambda expression a static?)

    Read the article

  • What is corresponding Cron expression to fire in every X seconds, where X > 60?

    - by giolekva
    I want my jobs to execute in every X seconds, there's one to one matching between job and X. Also during runtime there can be registered new jobs with their own intervals. I've tried to write cron expression for such scenarios, but in documentation there's written that value of seconds can't be more than 69. So cron expression like this: "0/63 * * * * ?" isn't valid. At first sight solution of that problem seemed to be expression like this: "0/3 0/1 * * * ?", but it means completely different thing: trigger job in every three second of every minute. Can you suggest what is the right solution (cron expression) for that? I know I could use just simple timers, but I've to use cron jobs using Quartz.

    Read the article

  • Building 'flat' rather than 'tree' LINQ expressions

    - by Ian Gregory
    I'm using some code (available here on MSDN) to dynamically build LINQ expressions containing multiple OR 'clauses'. The relevant code is var equals = values.Select(value => (Expression)Expression.Equal(valueSelector.Body, Expression.Constant(value, typeof(TValue)))); var body = equals.Aggregate<Expression>((accumulate, equal) => Expression.Or(accumulate, equal)); This generates a LINQ expression that looks something like this: (((((ID = 5) OR (ID = 4)) OR (ID = 3)) OR (ID = 2)) OR (ID = 1)) I'm hitting the recursion limit (100) when using this expression, so I'd like to generate an expression that looks like this: (ID = 5) OR (ID = 4) OR (ID = 3) OR (ID = 2) OR (ID = 1) How would I modify the expression building code to do this?

    Read the article

  • Is there a simple library that will render JSON objects as trees?

    - by Robert Gould
    So, is there a VERY simple library that will render JSON objects as trees? I know that this can be done in many ways (such as YUI), but for debug purposes I'd like to simply be able to view a JSON objects I receive from a server as a tree, nothing fancy (but collapsable tree's would be a bonus). The kind of solution I'm looking for would be something like: <script source="something.js"/> <script> obj ={"hello":"world"} lib.renderJSON("someid",obj); </script> ... <div id="someid"/> Any ideas?

    Read the article

  • How can I make this work with deep properties

    - by Martin Robins
    Given the following code... class Program { static void Main(string[] args) { Foo foo = new Foo { Bar = new Bar { Name = "Martin" }, Name = "Martin" }; DoLambdaStuff(foo, f => f.Name); DoLambdaStuff(foo, f => f.Bar.Name); } static void DoLambdaStuff<TObject, TValue>(TObject obj, Expression<Func<TObject, TValue>> expression) { // Set up and test "getter"... Func<TObject, TValue> getValue = expression.Compile(); TValue stuff = getValue(obj); // Set up and test "setter"... ParameterExpression objectParameterExpression = Expression.Parameter(typeof(TObject)), valueParameterExpression = Expression.Parameter(typeof(TValue)); Expression<Action<TObject, TValue>> setValueExpression = Expression.Lambda<Action<TObject, TValue>>( Expression.Block( Expression.Assign(Expression.Property(objectParameterExpression, ((MemberExpression)expression.Body).Member.Name), valueParameterExpression) ), objectParameterExpression, valueParameterExpression ); Action<TObject, TValue> setValue = setValueExpression.Compile(); setValue(obj, stuff); } } class Foo { public Bar Bar { get; set; } public string Name { get; set; } } class Bar { public string Name { get; set; } } The call to DoLambdaStuff(foo, f => f.Name) works ok because I am accessing a shallow property, however the call to DoLambdaStuff(foo, f => f.Bar.Name) fails - although the creation of the getValue function works fine, the creation of the setValueExpression fails because I am attempting to access a deep property of the object. Can anybody please help me to modify this so that I can create the setValueExpression for deep properties as well as shallow? Thanks.

    Read the article

  • How to construct LambdaExpression with conversion

    - by nerijus
    I need to sort in ajax response grid by column name. Column value is number stored as a string. Let's say some trivial class (in real-life situation there is no possibility to modify this class): class TestObject { public TestObject(string v) { this.Value = v; } public string Value { get; set; } } then simple test: [Test] public void LambdaConstructionTest() { var queryable = new List<TestObject> { new TestObject("5"), new TestObject("55"), new TestObject("90"), new TestObject("9"), new TestObject("09"), new TestObject("900"), }.AsQueryable(); var sortingColumn = "Value"; ParameterExpression parameter = Expression.Parameter(queryable.ElementType); MemberExpression property = Expression.Property(parameter, sortingColumn); //// tried this one: var c = Expression.Convert(property, typeof(double)); LambdaExpression lambda = Expression.Lambda(property, parameter); //// constructs: o=>o.Value var callExpression = Expression.Call(typeof (Double), "Parse", null, property); var methodCallExpression = Expression.Call( typeof(Queryable), "OrderBy", new[] { queryable.ElementType, property.Type }, queryable.Expression, Expression.Quote(lambda)); // works, but sorts by string values. //Expression.Quote(callExpression)); // getting: System.ArgumentException {"Quoted expression must be a lambda"} var querable = queryable.Provider.CreateQuery<TestObject>(methodCallExpression); // return querable; // <- this is the return of what I need. } Sorry for not being clear in my first post as @SLaks answer was correct but I do not know how to construct correct lambda expression in this case.

    Read the article

  • GridView ObjectDataSource LINQ Paging and Sorting using multiple table query.

    - by user367426
    I am trying to create a pageing and sorting object data source that before execution returns all results, then sorts on these results before filtering and then using the take and skip methods with the aim of retrieving just a subset of results from the database (saving on database traffic). this is based on the following article: http://www.singingeels.com/Blogs/Nullable/2008/03/26/Dynamic_LINQ_OrderBy_using_String_Names.aspx Now I have managed to get this working even creating lambda expressions to reflect the sort expression returned from the grid even finding out the data type to sort for DateTime and Decimal. public static string GetReturnType<TInput>(string value) { var param = Expression.Parameter(typeof(TInput), "o"); Expression a = Expression.Property(param, "DisplayPriceType"); Expression b = Expression.Property(a, "Name"); Expression converted = Expression.Convert(Expression.Property(param, value), typeof(object)); Expression<Func<TInput, object>> mySortExpression = Expression.Lambda<Func<TInput, object>>(converted, param); UnaryExpression member = (UnaryExpression)mySortExpression.Body; return member.Operand.Type.FullName; } Now the problem I have is that many of the Queries return joined tables and I would like to sort on fields from the other tables. So when executing a query you can create a function that will assign the properties from other tables to properties created in the partial class. public static Account InitAccount(Account account) { account.CurrencyName = account.Currency.Name; account.PriceTypeName = account.DisplayPriceType.Name; return account; } So my question is, is there a way to assign the value from the joined table to the property of the current table partial class? i have tried using. from a in dc.Accounts where a.CompanyID == companyID && a.Archived == null select new { PriceTypeName = a.DisplayPriceType.Name}) but this seems to mess up my SortExpression. Any help on this would be much appreciated, I do understand that this is complex stuff.

    Read the article

  • How can I edit (in MS Expression Web ) FrontPage Site Parameters (Substitutions)?

    - by Clay Nichols
    Or, asked another way: Where are the values for MS Front Page Substitions (Site Parameters) stored? (so that I can edit in Web Expressions) Background I'm ashamed to admit that I've been maintaining our company's website in MS FrontPage for over 9 years. I'm moving it to Expression Web, which will display the Substitutions (stored as Site Parameters) but I can't figure out where to edit them. I tried searching the source folders for the website (on my development PC) for the name of the parameter (s-Variable=hoursOfOperation) but did not find it (other than in the files it was actually used in.

    Read the article

  • How can I improve the workflow between developer and designer with Expression Blend?

    - by Amenti
    We use WPF and Expression Blend 4. I'm trying to improve our workflow by tutoring one of our designers to use it for styling and animation. Slowly but surely I get the impression Blend in itself is to technical for the designer in question. I myself use it only occasionally (it's great for Visual States for instance) because a lot of things are easier done in code or not possible at all in Blend alone. It seems a developer with design experience is a lot more productive with it than a sole designer. Are there any good resources or advice as to how I can improve this workflow?

    Read the article

  • How to improve workflow between developer and designer with Expression Blend?

    - by Amenti
    We use WPF and Expression Blend 4. I'm trying to improve our workflow by tutoring one of our designers to use it for styling and animation. Slowly but surely I get the impression Blend in itself is to technical for the designer in question. I myself use it only occasionally (it's great for Visual States for instance) because a lot of things are easier done in code or not possible at all in Blend alone. It seems a developer with design experience is a lot more productive with it than a sole designer. Are there any good online resources or advice you could give me how to improve this situation?

    Read the article

  • Access 2007: How can I make this EXPRESSION less complex?

    - by Mike
    Access is telling me that my new expression is to complex. It used to work when we had 10 service levels, but now we have 19! Great! My expression is checking the COST of our services in the [PriceCharged] field and then assigning the appropriate HOURS [Servicelevel] when I perform a calculation to work out how much REVENUE each colleague has made when working for a client. The [EstimatedTime] field stores the actual hours each colleague has worked. [EstimatedTime]/[ServiceLevel]*[PriceCharged] Great. Below is the breakdown of my COST to HOURS expression. I've put them on different lines to make it easier to read - please do not be put off by the length of this post, it's all the same info in the end. Many thanks,Mike ServiceLevel: IIf([pricecharged]=100(COST),6(HOURS), IIf([pricecharged]=200 Or [pricecharged]=210,12.5, IIf([pricecharged]=300,19, IIf([pricecharged]=400 Or [pricecharged]=410,25, IIf([pricecharged]=500,31, IIf([pricecharged]=600,37.5, IIf([pricecharged]=700,43, IIf([pricecharged]=800 Or [pricecharged]=810,50, IIf([pricecharged]=900,56, IIf([pricecharged]=1000,62.5, IIf([pricecharged]=1100,69, IIf([pricecharged]=1200 Or [pricecharged]=1210,75, IIf([pricecharged]=1300 Or [pricecharged]=1310,100, IIf([pricecharged]=1400,125, IIf([pricecharged]=1500,150, IIf([pricecharged]=1600,175, IIf([pricecharged]=1700,200, IIf([pricecharged]=1800,225, IIf([pricecharged]=1900,250,0)))))))))))))))))))

    Read the article

  • Knockout with ASP.Net MVC2 - HTML Extension Helpers for input controls

    - by Renso
    Goal: Defining Knockout-style input controls can be tedious and also may be something that you may find obtrusive, mixing your HTML with data bind syntax as well as binding your aspx, ascx files to Knockout. The goal is to make specifying Knockout specific HTML tags easy, seamless really, as well as being able to remove references to Knockout easily. Environment considerations: ASP.Net MVC2 or later Knockoutjs.js How to:     public static class HtmlExtensions     {         public static string DataBoundCheckBox(this HtmlHelper helper, string name, bool isChecked, object htmlAttributes)         {             var builder = new TagBuilder("input");             var dic = new RouteValueDictionary(htmlAttributes) { { "data-bind", String.Format("checked: {0}", name) } };             builder.MergeAttributes(dic);             builder.MergeAttribute("type", @"checkbox");             builder.MergeAttribute("name", name);             builder.MergeAttribute("value", @"true");             if (isChecked)             {                 builder.MergeAttribute("checked", @"checked");             }             return builder.ToString(TagRenderMode.SelfClosing);         }         public static MvcHtmlString DataBoundSelectList(this HtmlHelper helper, string name, IEnumerable<SelectListItem> selectList, String optionLabel)         {             var attrProperties = new StringBuilder();             attrProperties.Append(String.Format("optionsText: '{0}'", name));             if (!String.IsNullOrEmpty(optionLabel)) attrProperties.Append(String.Format(", optionsCaption: '{0}'", optionLabel));             attrProperties.Append(String.Format(", value: {0}", name));             var dic = new RouteValueDictionary { { "data-bind", attrProperties.ToString() } };             return helper.DropDownList(name, selectList, optionLabel, dic);         }         public static MvcHtmlString DataBoundSelectList(this HtmlHelper helper, string name, IEnumerable<SelectListItem> selectList, String optionLabel, object htmlAttributes)         {             var attrProperties = new StringBuilder();             attrProperties.Append(String.Format("optionsText: '{0}'", name));             if (!String.IsNullOrEmpty(optionLabel)) attrProperties.Append(String.Format(", optionsCaption: '{0}'", optionLabel));             attrProperties.Append(String.Format(", value: {0}", name));             var dic = new RouteValueDictionary(htmlAttributes) {{"data-bind", attrProperties}};             return helper.DropDownList(name, selectList, optionLabel, dic);         }         public static String DataBoundSelectList(this HtmlHelper helper, String options, String optionsText, String value)         {             return String.Format("<select data-bind=\"options: {0},optionsText: '{1}',value: {2}\"></select>", options, optionsText, value);         }         public static MvcHtmlString DataBoundTextBox(this HtmlHelper helper, string name, object value, object htmlAttributes)         {             var dic = new RouteValueDictionary(htmlAttributes);             dic.Add("data-bind", String.Format("value: {0}", name));             return helper.TextBox(name, value, dic);         }         public static MvcHtmlString DataBoundTextBox(this HtmlHelper helper, string name, string observable, object value, object htmlAttributes)         {             var dic = new RouteValueDictionary(htmlAttributes);             dic.Add("data-bind", String.Format("value: {0}", observable));             return helper.TextBox(name, value, dic);         }         public static MvcHtmlString DataBoundTextArea(this HtmlHelper helper, string name, string value, int rows, int columns, object htmlAttributes)         {             var dic = new RouteValueDictionary(htmlAttributes);             dic.Add("data-bind", String.Format("value: {0}", name));             return helper.TextArea(name, value, rows, columns, dic);         }         public static MvcHtmlString DataBoundTextArea(this HtmlHelper helper, string name, string observable, string value, int rows, int columns, object htmlAttributes)         {             var dic = new RouteValueDictionary(htmlAttributes);             dic.Add("data-bind", String.Format("value: {0}", observable));             return helper.TextArea(name, value, rows, columns, dic);         }         public static string BuildUrlFromExpression<T>(this HtmlHelper helper, Expression<Action<T>> action)         {             var values = CreateRouteValuesFromExpression(action);             var virtualPath = helper.RouteCollection.GetVirtualPath(helper.ViewContext.RequestContext, values);             if (virtualPath != null)             {                 return virtualPath.VirtualPath;             }             return null;         }         public static string ActionLink<T>(this HtmlHelper helper, Expression<Action<T>> action, string linkText)         {             return helper.ActionLink(action, linkText, null);         }         public static string ActionLink<T>(this HtmlHelper helper, Expression<Action<T>> action, string linkText, object htmlAttributes)         {             var values = CreateRouteValuesFromExpression(action);             var controllerName = (string)values["controller"];             var actionName = (string)values["action"];             values.Remove("controller");             values.Remove("action");             return helper.ActionLink(linkText, actionName, controllerName, values, new RouteValueDictionary(htmlAttributes)).ToHtmlString();         }         public static MvcForm Form<T>(this HtmlHelper helper, Expression<Action<T>> action)         {             return helper.Form(action, FormMethod.Post);         }         public static MvcForm Form<T>(this HtmlHelper helper, Expression<Action<T>> action, FormMethod method)         {             var values = CreateRouteValuesFromExpression(action);             string controllerName = (string)values["controller"];             string actionName = (string)values["action"];             values.Remove("controller");             values.Remove("action");             return helper.BeginForm(actionName, controllerName, values, method);         }         public static MvcForm Form<T>(this HtmlHelper helper, Expression<Action<T>> action, FormMethod method, object htmlAttributes)         {             var values = CreateRouteValuesFromExpression(action);             string controllerName = (string)values["controller"];             string actionName = (string)values["action"];             values.Remove("controller");             values.Remove("action");             return helper.BeginForm(actionName, controllerName, values, method, new RouteValueDictionary(htmlAttributes));         }         public static string VertCheckBox(this HtmlHelper helper, string name, bool isChecked)         {             return helper.CustomCheckBox(name, isChecked, null);         }          public static string CustomCheckBox(this HtmlHelper helper, string name, bool isChecked, object htmlAttributes)         {             TagBuilder builder = new TagBuilder("input");             builder.MergeAttributes(new RouteValueDictionary(htmlAttributes));             builder.MergeAttribute("type", "checkbox");             builder.MergeAttribute("name", name);             builder.MergeAttribute("value", "true");             if (isChecked)             {                 builder.MergeAttribute("checked", "checked");             }             return builder.ToString(TagRenderMode.SelfClosing);         }         public static string Script(this HtmlHelper helper, string script, object scriptAttributes)         {             var pathForCRMScripts = ScriptsController.GetPathForCRMScripts();             if (ScriptOptimizerConfig.EnableMinimizedFileLoad)             {                 string newPathForCRM = pathForCRMScripts + "Min/";                 ScriptsController.ServerPathMapper = new ServerPathMapper();                 string fullPath = ScriptsController.ServerMapPath(newPathForCRM);                 if (!File.Exists(fullPath + script))                     return null;                 if (!Directory.Exists(fullPath))                     return null;                 pathForCRMScripts = newPathForCRM;             }             var builder = new TagBuilder("script");             builder.MergeAttributes(new RouteValueDictionary(scriptAttributes));             builder.MergeAttribute("type", @"text/javascript");             builder.MergeAttribute("src", String.Format("{0}{1}", pathForCRMScripts.Replace("~", String.Empty), script));             return builder.ToString(TagRenderMode.SelfClosing);         }         private static RouteValueDictionary CreateRouteValuesFromExpression<T>(Expression<Action<T>> action)         {             if (action == null)                 throw new InvalidOperationException("Action must be provided");             var body = action.Body as MethodCallExpression;             if (body == null)             {                 throw new InvalidOperationException("Expression must be a method call");             }             if (body.Object != action.Parameters[0])             {                 throw new InvalidOperationException("Method call must target lambda argument");             }             // This will build up a RouteValueDictionary containing the controller name, action name, and any             // parameters passed as part of the "action" parameter.             string name = body.Method.Name;             string controllerName = typeof(T).Name;             if (controllerName.EndsWith("Controller", StringComparison.OrdinalIgnoreCase))             {                 controllerName = controllerName.Remove(controllerName.Length - 10, 10);             }             var values = BuildParameterValuesFromExpression(body) ?? new RouteValueDictionary();             values.Add("controller", controllerName);             values.Add("action", name);             return values;         }         private static RouteValueDictionary BuildParameterValuesFromExpression(MethodCallExpression call)         {             // Build up a RouteValueDictionary containing parameter names as keys and parameter values             // as values based on the MethodCallExpression passed in.             var values = new RouteValueDictionary();             ParameterInfo[] parameters = call.Method.GetParameters();             // If the passed in method has no parameters, just return an empty dictionary.             if (parameters.Length == 0)             {                 return values;             }             for (int i = 0; i < parameters.Length; i++)             {                 object parameterValue;                 Expression expression = call.Arguments[i];                 // If the current parameter is a constant, just use its value as the parameter value.                 var constant = expression as ConstantExpression;                 if (constant != null)                 {                     parameterValue = constant.Value;                 }                 else                 {                     // Otherwise, compile and execute the expression and use that as the parameter value.                     var function = Expression.Lambda<Func<object>>(Expression.Convert(expression, typeof(object)),                                                                    new ParameterExpression[0]);                     try                     {                         parameterValue = function.Compile()();                     }                     catch                     {                         parameterValue = null;                     }                 }                 values.Add(parameters[i].Name, parameterValue);             }             return values;         }     }   Some observations: The first two DataBoundSelectList overloaded methods are specifically built to load the data right into the drop down box as part of the HTML response stream rather than let Knockout's engine populate the options client-side. The third overloaded method does it client-side via the viewmodel. The first two overloads can be done when you have no requirement to add complex JSON objects to your lists. Furthermore, why render and parse the JSON object when you can have it all built and rendered server-side like any other list control.

    Read the article

  • Does a successful exit of rsync -acvvv s d guarantee identical directory trees?

    - by user259774
    I have two volumes, one xfs, and another ntfs - ntfs was empty, and xfs had 10 subitems. I needed to sync them. I initially copied a few of the subitems by dragging them over in a gui fm. Several of the direct descendants which i had dragged finished, apparently. One I stopped before it was done, and the rest I cancelled while it still appeared to be gathering information about the files. Then I ran rsync -acvvv xmp/ nmp/, where xmp and nmp are the volumes' respective mountpoints, which exited with a 0 status. find xmp -printf x | wc -c and find nmp -printf x | wc -c both return 372926. My question is: Am I guaranteed that the two drives' contents are identical?

    Read the article

  • Is there a program that will show a tree of the differences in two file trees?

    - by Huckle
    In windows I manually back up from time to time by formatting my external drive and copying the contents of my data partition over. Inevitably there is a difference in the number and size of the files copied because of system files, etc. Is there a program that would diff two directories recursively and compile the differences into a nice GUI tree that I could peruse (preferably filter) to ensure that everything I want made it over to the drive? It should only show files that are not in both directories. (Also, please ignore the inadequacy of my backup solution)

    Read the article

  • Why do I get this Debug Assertion Failed? Expression: list iterator not dereferenceable [migrated]

    - by Karel
    I'm trying this example in the (translated to dutch) book of Bjarne Stroustrup (C++): #include <vector> #include <list> #include "complex.h" complex ac[200]; std::vector<complex> vc; std::list<complex> l; template<class In, class Out> void Copy(In from, In too_far, Out to) { while(from != too_far) { *to = *from; ++to; ++from; } } void g(std::vector<complex>& vc , std::list<complex>& lc) { Copy(&ac[0], &ac[200], lc.begin()); // generates debug error Copy(lc.begin(), lc.end(), vc.begin()); // also generates debug error } void f() { ac[0] = complex(10,20); g(vc, l); } int main () { f(); } ** Compiling and Linking goes successful (0 errors/warnings)** But at runtime I get this error: Debug Assertion Failed! Program: path to exe file: \program files\ms vs studio 10.0\vc\include\list Line: 207 Expression: list iterator not dereferenceable For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts. (Press retry to debug the application)

    Read the article

  • Deterministic/Consistent Unique Masking

    - by Dinesh Rajasekharan-Oracle
    One of the key requirements while masking data in large databases or multi database environment is to consistently mask some columns, i.e. for a given input the output should always be the same. At the same time the masked output should not be predictable. Deterministic masking also eliminates the need to spend enormous amount of time spent in identifying data relationships, i.e. parent and child relationships among columns defined in the application tables. In this blog post I will explain different ways of consistently masking the data across databases using Oracle Data Masking and Subsetting The readers of post should have minimal knowledge on Oracle Enterprise Manager 12c, Application Data Modeling, Data Masking concepts. For more information on these concepts, please refer to Oracle Data Masking and Subsetting document Oracle Data Masking and Subsetting 12c provides four methods using which users can consistently yet irreversibly mask their inputs. 1. Substitute 2. SQL Expression 3. Encrypt 4. User Defined Function SUBSTITUTE The substitute masking format replaces the original value with a value from a pre-created database table. As the method uses a hash based algorithm in the back end the mappings are consistent. For example consider DEPARTMENT_ID in EMPLOYEES table is replaced with FAKE_DEPARTMENT_ID from FAKE_TABLE. The substitute masking transformation that all occurrences of DEPARTMENT_ID say ‘101’ will be replaced with ‘502’ provided same substitution table and column is used , i.e. FAKE_TABLE.FAKE_DEPARTMENT_ID. The following screen shot shows the usage of the Substitute masking format with in a masking definition: Note that the uniqueness of the masked value depends on the number of columns being used in the substitution table i.e. if the original table contains 50000 unique values, then for the masked output to be unique and deterministic the substitution column should also contain 50000 unique values without which only consistency is maintained but not uniqueness. SQL EXPRESSION SQL Expression replaces an existing value with the output of a specified SQL Expression. For example while masking an EMPLOYEES table the EMAIL_ID of an employee has to be in the format EMPLOYEE’s [email protected] while FIRST_NAME and LAST_NAME are the actual column names of the EMPLOYEES table then the corresponding SQL Expression will look like %FIRST_NAME%||’.’||%LAST_NAME%||’@COMPANY.COM’. The advantage of this technique is that if you are masking FIRST_NAME and LAST_NAME of the EMPLOYEES table than the corresponding EMAIL ID will be replaced accordingly by the masking scripts. One of the interesting aspect’s of a SQL Expressions is that you can use sub SQL expressions, which means that you can write a nested SQL and use it as SQL Expression to address a complex masking business use cases. SQL Expression can also be used to consistently replace value with hashed value using Oracle’s PL/SQL function ORA_HASH. The following SQL Expression will help in the previous example for replacing the DEPARTMENT_IDs with a hashed number ORA_HASH (%DEPARTMENT_ID%, 1000) The following screen shot shows the usage of encrypt masking format with in the masking definition: ORA_HASH takes three arguments: 1. Expression which can be of any data type except LONG, LOB, User Defined Type [nested table type is allowed]. In the above example I used the Original value as expression. 2. Number of hash buckets which can be number between 0 and 4294967295. The default value is 4294967295. You can also co-relate the number of hash buckets to a range of numbers. In the above example above the bucket value is specified as 1000, so the end result will be a hashed number in between 0 and 1000. 3. Seed, can be any number which decides the consistency, i.e. for a given seed value the output will always be same. The default seed is 0. In the above SQL Expression a seed in not specified, so it to 0. If you have to use a non default seed then the function will look like. ORA_HASH (%DEPARTMENT_ID%, 1000, 1234 The uniqueness depends on the input and the number of hash buckets used. However as ORA_HASH uses a 32 bit algorithm, considering birthday paradox or pigeonhole principle there is a 0.5 probability of collision after 232-1 unique values. ENCRYPT Encrypt masking format uses a blend of 3DES encryption algorithm, hashing, and regular expression to produce a deterministic and unique masked output. The format of the masked output corresponds to the specified regular expression. As this technique uses a key [string] to encrypt the data, the same string can be used to decrypt the data. The key also acts as seed to maintain consistent outputs for a given input. The following screen shot shows the usage of encrypt masking format with in the masking definition: Regular Expressions may look complex for the first time users but you will soon realize that it’s a simple language. There are many resources in internet, oracle documentation, oracle learning library, my oracle support on writing a Regular Expressions, out of all the following My Oracle Support document helped me to get started with Regular Expressions: Oracle SQL Support for Regular Expressions[Video](Doc ID 1369668.1) USER DEFINED FUNCTION [UDF] User Defined Function or UDF provides flexibility for the users to code their own masking logic in PL/SQL, which can be called from masking Defintion. The standard format of an UDF in Oracle Data Masking and Subsetting is: Function udf_func (rowid varchar2, column_name varchar2, original_value varchar2) returns varchar2; Where • rowid is the row identifier of the column that needs to be masked • column_name is the name of the column that needs to be masked • original_value is the column value that needs to be masked You can achieve deterministic masking by using Oracle’s built in hash functions like, ORA_HASH, DBMS_CRYPTO.MD4, DBMS_CRYPTO.MD5, DBMS_UTILITY. GET_HASH_VALUE.Please refers to the Oracle Database Documentation for more information on the Oracle Hash functions. For example the following masking UDF generate deterministic unique hexadecimal values for a given string input: CREATE OR REPLACE FUNCTION RD_DUX (rid varchar2, column_name varchar2, orig_val VARCHAR2) RETURN VARCHAR2 DETERMINISTIC PARALLEL_ENABLE IS stext varchar2 (26); no_of_characters number(2); BEGIN no_of_characters:=6; stext:=substr(RAWTOHEX(DBMS_CRYPTO.HASH(UTL_RAW.CAST_TO_RAW(text),1)),0,no_of_characters); RETURN stext; END; The uniqueness depends on the input and length of the string and number of bits used by hash algorithm. In the above function MD4 hash is used [denoted by argument 1 in the DBMS_CRYPTO.HASH function which is a 128 bit algorithm which produces 2^128-1 unique hashed values , however this is limited by the length of the input string which is 6, so only 6^6 unique values will be generated. Also do not forget about the birthday paradox/pigeonhole principle mentioned earlier in this post. An another example is to consistently replace characters or numbers preserving the length and special characters as shown below: CREATE OR REPLACE FUNCTION RD_DUS(rid varchar2,column_name varchar2,orig_val VARCHAR2) RETURN VARCHAR2 DETERMINISTIC PARALLEL_ENABLE IS stext varchar2(26); BEGIN DBMS_RANDOM.SEED(orig_val); stext:=TRANSLATE(orig_val,'ABCDEFGHILKLMNOPQRSTUVWXYZ',DBMS_RANDOM.STRING('U',26)); stext:=TRANSLATE(stext,'abcdefghijklmnopqrstuvwxyz',DBMS_RANDOM.STRING('L',26)); stext:=TRANSLATE(stext,'0123456789',to_char(DBMS_RANDOM.VALUE(1,9))); stext:=REPLACE(stext,'.','0'); RETURN stext; END; The following screen shot shows the usage of an UDF with in a masking definition: To summarize, Oracle Data Masking and Subsetting helps you to consistently mask data across databases using one or all of the methods described in this post. It saves the hassle of identifying the parent-child relationships defined in the application table. Happy Masking

    Read the article

  • How can I update an expression in a Runt::Schedule object?

    - by Reid Beels
    Runt provides a Schedule class for managing collections of events, each represented by a temporal expression. The Schedule class provides an update method, cited in the release notes as "allowing clients to update existing expressions". The implementation of this method, however, simply calls a supplied block, providing the temporal expression for the specified event (as shown). # From lib/runt/schedule.rb:61 # # Call the supplied block/Proc with the currently configured # TemporalExpression associated with the supplied Event. # def update(event,&block) block.call(@elems[event]) end How is one expected to use this method to update an expression?

    Read the article

  • How to stop ReSharper from showing error on a lambda expression where Action is expected?

    - by carlmon
    In Silverlight, System.Windows.Threading's Dispatcher.BeginInvoke() takes an Action<T> or a delegate to invoke. .NET allows me to pass just the lambda expression. but ReSharper sees it as an error, saying "Cannot resolve method 'BeginInvoke(lambda expression)'": Dispatcher.BeginInvoke(() => { DoSomething(); }) The error goes away if I explicitly create the Action around the expression like this: Dispatcher.BeginInvoke(new Action<object>(o => { DoSomething(); })); I prefer the least amount of code in this case for the best readability. Is there a way to disable this specific ReSharper error notification? I tried some of the options, but could not find it. Thanks, Carl

    Read the article

  • Phone Number validation using Regular Expression validation in c# 2008?

    - by prateeksaluja20
    Hello Experts , I Want to validate the phone number in this format i.e +919981424199,+91231456789,.... I am using Asp.net +c#2008 for developing web site.for this i have used the Regular Expression validation control-property-Validation Expression="[0-9]+(,[0-9]+)*". But this accept the number as 919981424199,..... User may be enter in this way +919981424199,919300951916,so on so i need the validation expression for this type format.The "+" symbol is optional it can be use & it can't.I tried to solve but still i am searching.please help me to sort out this problem. thanks in advance.

    Read the article

  • what is regular expression not generated over {a,b}?

    - by Loop
    Hello all, I am really stuck with these 2 question for over 2 days now. trying to figure out what the question means.... my tutor is out of town too.... write a regular expression for the only strings that are not generated over {a,b} by the expression: (a+b)*a(a+b)*. explain your reasoning. and i tried the second question, do you think is there any better answer than this one? what is regular expression of set of string that contain an odd number of a's or exactly two b's................(a((a|b)(a|b))*|bb).... coz i know to represent any odd length of a's, the RE is a((a|b)(a|b))*

    Read the article

  • shift reduce&& reduce reduce errors in build parser for python garmmer

    - by user366580
    i wanna build buttom up parser by java cup i write code in java cup , it is for python language so i used grammer was written in this site : but not all grammer , i choice partial set ,just while , identifer also i smiplified them when i did compile for the java cup that i write by write this command in command prompt window : java java_cup.Main -parser CalcParser -symbols CalcSymbol < javacupfile.cup i get conflict errors ,they are of type reduce-shift conflict and reduce-reduce conflict you can see to print screen of the errors in these links image 1 click here to see imge1 the grammer was in EBNF form in as refernce site and i convert it to BNF form maybe i make mistake in converting so i get such errors the origanl grammmer was // grammer in EBNF form identifier ::= (letter|"_") (letter | digit | "_")* letter ::= lowercase | uppercase lowercase ::= "a"..."z" uppercase ::= "A"..."Z" digit ::= "0"..."9 compound_stmt ::= if_stmt | while_stmt for_stmt ::= "for" target_list "in" expression_list ":" suite ["else" ":" suite] while_stmt ::= "while" expression ":" suite ["else" ":" suite] suite ::= stmt_list NEWLINE stmt_list ::= simple_stmt (";" simple_stmt)* [";"] simple_stmt ::= expression_stmt expression_stmt ::= expression_list expression_list ::= expression ( "," expression )* [","] expression ::= conditional_expression conditional_expression ::= or_test ["if" or_test "else" expression] or_test ::= and_test | or_test "or" and_test and_test ::= not_test | and_test "and" not_test not_test ::= comparison | "not" not_test comparison ::= or_expr ( comp_operator or_expr )* comp_operator ::= "<" | ">" | "==" | ">=" | "<=" | "<>" | "!=" | "is" ["not"] | ["not"] "in" or_expr ::= xor_expr | or_expr "|" xor_expr xor_expr ::= and_expr | xor_expr "^" and_expr and_expr ::= "&" | and_expr the grammer after converting to BNF form identifier ::=letterletter| letterdigit| letter"_"| "_"letter | "_"digit | "_""_" letter ::= lowercase | uppercase lowercase ::= "a"..."z" uppercase ::= "A"..."Z" digit ::= "0"..."9 while_stmt ::= "while" expression ":" suite "else" ":" suite |"while" expression ":" suite suite ::= stmt_list NEWLINE stmt_list ::= simple_stmt ";" simple_stmt stmt_list|";" simple_stmt ::= expression_stmt expression_stmt ::= expression_list expression_list ::= expression "," expression expression_list| "," expression ::= conditional_expression conditional_expression ::= or_test "if" or_test "else" expression |or_test or_test ::= and_test | or_test "or" and_test and_test ::= not_test | and_test "and" not_test not_test ::= comparison | "not" not_test comparison ::= or_expr comp_operator or_expr comp_operator ::= "<" | ">" | "==" | ">=" | "<=" | "<>" | "!=" | "is" ["not"] | ["not"] "in" or_expr ::= xor_expr | or_expr "|" xor_expr xor_expr ::= and_expr | xor_expr "^" and_expr and_expr ::= "&" | and_expr and the java cup file that i compile and get those errors is import java.io.*; terminal COMA; terminal ELSE; terminal WHILE; terminal NEWLINE; terminal SEMCOLON; terminal CAMMA; terminal IF; terminal OR; terminal AND; terminal NOT; terminal LESS; terminal GREATER; terminal EQUAL; terminal GREATERorE; terminal LESSorE; terminal NEQUAL; terminal OROP; terminal XOROP; terminal ANDOP; terminal Integer DIGIT; terminal java.lang.String LOWERCASE; terminal java.lang.String UPPERCASE; non terminal java.lang.String IDENTIFIER; non terminal java.lang.String LETTER; non terminal COMPOUND_STMT; non terminal WHILE_STMT; non terminal EXPRESSION; non terminal SUITE ; non terminal STMT_LIST; non terminal SIMPLE_STMT; non terminal EXPRESSION_STMT; non terminal EXPRESSION_LIST; non terminal CONDITITONAL_EXPRESSION; non terminal OR_TEST; non terminal AND_TEST; non terminal NOT_TEST; non terminal COMPARISON; non terminal COMP_OPERATOR; non terminal OR_EXPR; non terminal XOR_EXPR; non terminal AND_EXPR; IDENTIFIER ::=LETTER{: System.out.printf("lowercase"); :}| {: System.out.printf("uppercase"); :} LETTER{: System.out.printf("lowercase"); :}| {: System.out.printf("uppercase"); :}| LETTER{: System.out.printf("lowercase"); :}| {: System.out.printf("uppercase"); :} DIGIT; LETTER ::= LOWERCASE | UPPERCASE; COMPOUND_STMT ::=WHILE_STMT; WHILE_STMT ::= WHILE{: System.out.printf( "while"); :} EXPRESSION COMA {: System.out.printf(":"); :} SUITE ELSE {: System.out.printf("else" ); :} COMA{: System.out.printf( ":" ); :} SUITE |WHILE{: System.out.printf( "while" ); :} EXPRESSION COMA{: System.out.printf( ":" ); :} SUITE; SUITE ::= STMT_LIST NEWLINE{: System.out.printf( "newline" ); :}; STMT_LIST ::= SIMPLE_STMT SEMCOLON{: System.out.printf( ";" ); :} SIMPLE_STMT STMT_LIST|SEMCOLON{: System.out.printf( ";" ); :}; SIMPLE_STMT ::=EXPRESSION_STMT; EXPRESSION_STMT ::=EXPRESSION_LIST; EXPRESSION_LIST ::= EXPRESSION CAMMA{: System.out.printf( "," ); :} EXPRESSION EXPRESSION_LIST| CAMMA{: System.out.printf( "," ); :}; EXPRESSION ::= CONDITITONAL_EXPRESSION; CONDITITONAL_EXPRESSION ::= OR_TEST IF{: System.out.printf( "if"); :} OR_TEST ELSE{: System.out.printf("else"); :} EXPRESSION |OR_TEST; OR_TEST ::= AND_TEST | OR_TEST OR{: System.out.printf( "or"); :} AND_TEST; AND_TEST ::= NOT_TEST | AND_TEST AND{: System.out.printf( "and"); :} NOT_TEST; NOT_TEST ::= COMPARISON | NOT{: System.out.printf("not"); :} NOT_TEST; COMPARISON ::= OR_EXPR COMP_OPERATOR OR_EXPR ; COMP_OPERATOR ::= LESS{: System.out.printf( "<"); :} | GREATER{: System.out.printf(">"); :} | EQUAL{: System.out.printf("=="); :} | GREATERorE{: System.out.printf(">="); :} | LESSorE{: System.out.printf("<="); :} | NEQUAL{: System.out.printf("!="); :}; OR_EXPR ::= XOR_EXPR | OR_EXPR OROP{: System.out.printf("|"); :} XOR_EXPR; XOR_EXPR ::= AND_EXPR | XOR_EXPR XOROP {: System.out.printf("^"); :}XOR_EXPR; AND_EXPR ::= ANDOP{: System.out.printf("&"); :} | AND_EXPR; can any one told me how can solve this errors to build parser correcrtly??

    Read the article

  • Is it possible to create ICriteria/ICriterion from LINQ or HQL?

    - by adrin
    I am creating a method that can create filter understood by NHibernate (by filter i mean a set of ICriteria object for example) from my abstract filter object. public static IEnumerable<ICriterion> ToNhCriteria(this MyCriteria criteria) { // T4 generated function // lots of result.Add(Expression.Or(Expression.Eq(),Expression.Eq)) expression trees - hard to generate // Is there a way to generate HQL/Linq query here istead? } then i want to do something like session.CreateCriteria<Entity>().Add(myCriteria.ToNhCriteria()) to filter entities. The problem is that using Expression. methods (Expression.Or etc) is quite tedious (the method is generated and i have multiple or statements that have to be joined into an expression somehow). Is there a way to avoid using Expression.Or() and create ICrietrion / ICriteria using LINQ or HQL?

    Read the article

  • How to make that the LanguageBinder take precedence over the DynamicBinder

    - by rudimenter
    Hi I Have a class which implement IDynamicMetaObjectProvider I implement the BindGetMember Method from DynamicMetaObject. Now when i Generate a dynamic Object and Access a property every call gets implicit passed through the BindGetMember Method. I want that at first the language Binder get his chance before my code comes in. It is somehow doable with "binder.FallbackGetMember" but i am not sure how the expression has to look like. I call here dynamic com=CommandFactory.GetCommand(); com.testprop; //expected: "test"; but "test2" comes back public class Command : System.Dynamic.IDynamicMetaObjectProvider { public string testprop { get { return "test"; } } public object GetValue(string name) { return "test2"; } System.Dynamic.DynamicMetaObject System.Dynamic.IDynamicMetaObjectProvider.GetMetaObject(System.Linq.Expressions.Expression parameter) { return new MetaCommand(parameter, this); } private class MetaCommand : System.Dynamic.DynamicMetaObject { public MetaCommand(Expression expression, Command value) : base(expression, System.Dynamic.BindingRestrictions.Empty, value) { } public override System.Dynamic.DynamicMetaObject BindGetMember(System.Dynamic.GetMemberBinder binder) { var self = this.Expression; var bag = (Command)base.Value; Expression target; target = Expression.Call( Expression.Convert(self, typeof(Command)), typeof(Command).GetMethod("GetValue"), Expression.Constant(binder.Name) ); var restrictions = BindingRestrictions .GetInstanceRestriction(self, bag); return new DynamicMetaObject(target, restrictions); } #endregion } }

    Read the article

  • NHibernate Criteria question

    - by Jeneatte Jolie
    I have a person object, which can have unlimited number of first names. So the first names are another object. ie person --- name             --- name             --- name What I want to do is write an nhiberate query using which will get me a person who has certain names. so one query might be find someone whose names are alison and jane and philippa, then next query may be one to find someone whose names are alison and jane. I only want to return people who have all the names I'm search on. So far I've got ICriteria criteria = session.CreateCriteria(typeof (Person)); criteria.CreateAlias("Names", "name"); ICriterion expression = null; foreach (string name in namesToFind) { if (expression == null) { expression = Expression.Like("name.Value", "%" + name + "%"); } else { expression = Expression.Or( expression, Expression.Like("name.Value", "%" + name + "%")); } } if (expression != null) criteria.Add(expression); But this is returning every person with ANY of the names I'm searching on, not ALL the names. Can anyone help me out with this? Thanks!

    Read the article

< Previous Page | 53 54 55 56 57 58 59 60 61 62 63 64  | Next Page >